Reputation: 5500
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?
Upvotes: 0
Views: 2630
Reputation: 868
Executing the program from the folder that has the referenced dll can also solve the problem.
Upvotes: 0
Reputation: 178760
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.Upvotes: 3
Reputation: 21231
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.
Upvotes: 0
Reputation: 33108
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.
Upvotes: 0