I’m trying to load different versions of my dll while my host program is running. I can’t use different AppDomains and unload them, the reason is that my host program is just a test-setup and the real application (Autodesk 3ds Max) doesn’t support it and I can’t change anything about that. This is how I’m loading my dll in my test program:
var testAssembly = Assembly.LoadFrom(textBox1.Text);
var formObject = testAssembly.CreateInstance("Dll_Test.Form1");
(formObject as Form).Show();
I read here: https://msdn.microsoft.com/en-us/library/dd153782.aspx#load_contexts “If an assembly with the same identity is already loaded, LoadFrom returns the loaded assembly even if a different path was specified.”
So this is exactly my problem, at first I simply tried to rename my dll, compile my new one with some changes and call LoadFrom again. However, this didn’t show my changes and I assume this is because the assembly still has the same identity as the previous one. I thought I could change the identity by signing the assembly (https://msdn.microsoft.com/en-us/library/wd40t7ad.aspx). Unfortunately the third party dll I have to work with is not signed.
Is there a way to change the identity of my dll every time I compile without changing the Assembly name? This way I could keep using the same path string in Assembly.LoadFrom(path). If not I can work around the Assembly name change but some people had doubts about changing the Assembly name on every build (Unique Assembly name every build)