I have a dll called test and within test.dll, I’m referencing another dll called process. Now when I try loading test.dll, I get the error “System cannot find process.dll.
Please help
Assembly u = Assembly.LoadFile(@"C:\test\test.dll");
Type t = u.GetType("Test.Process");
MethodInfo m = t.GetMethod("ProcessFile");
try
{
object[] myparam = new object[1];
myparam[0] = @"C:\test\testFile.csv";
result = (string)m.Invoke(null, myparam);
Console.WriteLine(result);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message.ToString());
Console.WriteLine(ex.InnerException.ToString());
System.Threading.Thread.Sleep(100000);
}
I suspect you want
LoadFrominstead ofLoadFilein this case. The difference is that the extra path (c:\test) will be added to the “load from” context which will then be used for dependencies such asprocess.dll.At the moment, it’s trying to resolve
process.dllwithout takingc:\testinto consideration. Read the linked documentation for more information.