The assembly it's trying to find isn't the root assembly - it's a referenced one, but it's in the same folder, and Directory.GetCurrentDirectory() is the folder with all of the files in.
I'm stuck - any suggestions?
The assembly it's trying to find isn't the root assembly - it's a referenced one, but it's in the same folder, and Directory.GetCurrentDirectory() is the folder with all of the files in.
I'm stuck - any suggestions?
You can either:
AppDomain
to load the assembly (and set the AppDomain
's base directory to the directory containing all the assemblies).AppDomain.AssemblyResolve
to help the CLR find the assembly's dependencies.HTH, Kent
You could try using something like this
string myDll = string.Empty;
string location = Assembly.GetExecutingAssembly().Location;
if (location != null)
{
myDll = string.Format(@"{0}\my.assembly.name.dll", location.Substring(0, location.LastIndexOf(@"\")));
}
This should get physical directory in which the assemblies are running. This could be in the Windows .NET temporary directories. However, because the files are at the same level they should exist there side by side.
If you use assembly.loadfrom you can specify the file path to the assembly.
The load-from context allows an assembly to be loaded from a path not included in probing, and yet allows dependencies on that path to be found and loaded because the path information is maintained by the context.