In some situation, it can be useful to provide the runtime additional ways to resolve assemblies. There are two approach for this.
One way is to add .config file settings to specify additional paths for fusion to look at assemblies. This feature is called probing and you can read more about it here:
The other approach is to register an event handler on your app domain and provide the paths programmatically at runtime.
- Add a handler to this event
- AppDomain.CurrentDomain.AssemblyResolve += AssemblyResolver.CurrentDomain_AssemblyResolve;
- Inside this handler you can use Assembly.LoadFrom(..) and return the assembly. Note that if you cannot resolve the assembly, simply return null will fall back to fusion load process.
Important to note that if you are loading assemblies from file, I strongly recommend using LoadFrom method instead of Load, as Load from will not be aware of the version you are loading and could lead to performance and stability issues at runtime.