I have one assembly that is called asm.dll.
This assembly has the version 1.0.0.0 (set within AssemblyInfo.cs)
Then I need do do some code modifications in that assembly (still asm.dll), advance the version to 2.0.0.0 and build it again.
Now, I have two files named asm.dll that differ with respect to some code modifications and a their version number.
How do I load these two files during runtime?
ADDENDUM:
Right now I am trying the following:
var asm1 = Assembly.LoadFrom("dir1\asm.dll");
var asm2 = Assembly.LoadFrom("dir2\asm.dll");
var types1 = asm1.GetTypes();
var types2 = asm2.GetTypes();
Type type1 = types1.First<Type>(t => t.Name.Equals("myClassIWantToInstantiate"));
Type type2 = types2.First<Type>(t => t.Name.Equals("myClassIWantToInstantiate"));
MyObject myObject1 = (MyObject1)Activator.CreateInstance(type, new object[] { });
MyObject myObject2 = (MyObject2)Activator.CreateInstance(type, new object[] { });
But I get the following behavior:
the first call to
Activator.CreateInstance(...)correctly returns the requested instance formyObject1the second call to
Activator.CreateInstance(...)returns againmyObject1instead ofmyObject2The code compiles and the program runs without exception or observable problems, except that I do not get
myObject2
I am aware of this answer and I think the code I used, is the same, only a bit newer (correct me, if I am wrong).