tags:

views:

283

answers:

3

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?

+3  A: 

You can either:

  1. Create a new AppDomain to load the assembly (and set the AppDomain's base directory to the directory containing all the assemblies).
  2. Attach a handler for AppDomain.AssemblyResolve to help the CLR find the assembly's dependencies.
  3. You might be able to add the directory in question to the list of paths to probe. However, it will need to reside somewhere under your application's directory. See the probe element for more info.

HTH, Kent

Kent Boogaart
A: 

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.

Chris Marisic
A: 

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.

Aaron Fischer