So I have 2 different threads: thread1 and thread2, running with the following methods:
public static void thread1()
{
Assembly asm = Assembly.LoadFrom("t.dll");
Type t = asm.GetType("dis.Code");
Object Res = t.InvokeMember("Start", BindingFlags.InvokeMethod, null, null, null);
}
public static void thread2()
{
Assembly asm = Assembly.LoadFrom("test.dll");
Type t = asm.GetType("dis.Code");
Object Res = t.InvokeMember("Start", BindingFlags.InvokeMethod, null, null, null);
}
What I’m trying to do is to invoke 2 different files “t.dll” and “test.dll”. They’re both lying in the same directory as the .exe file containing the program above. The only thing the .dll files do, is a simple Console.WriteLine.
So here’s the problem: Calling one file with 1 or both threads results in success and will post the Console.WriteLine twice. However, once I call the 2 different files, 1 file with each thread, I end up with a NullReferenceException in the second call.
This is all coded in C#.
Please help 🙁
You can use extern alias and namespace alias qualifier to load types belonging to different assemblies but with same namespace.
This has been explained here and Using two .NET libraries with the same namespace.