Say we have an application which consists of one executable and 5 libraries. Regularly all of these will be contained in one directory and the libraries will be loaded from
If you want to manually manage where to get assembles from, you have two possibilities:
Handle the AppDomain.AssemblyResolve event (as it is described by SLaks). Here is the code snippet:
static void Main(string[] args)
{
...
AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve);
...
}
static System.Reflection.Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
{
string assembliesDir = "your_directory";
Assembly asm = Assembly.LoadFrom(Path.Combine(assembliesDir, args.Name + ".dll"));
return asm;
}
Create a domain with your own settings (by setting ApplicationBase or PrivateBinPath properties of the AppDomainSetup object).
So if you want to continue working in current domain you have to use method 1.