Imagine this scenario:
var ass1 = Assembly.LoadFrom(@"C:\Work\3.59\assembly1.dll");
var ass2 = Assembly.LoadFrom(@"C:\Work\3.60\assembly1.dll");
Debug.Assert(ass1 != ass2);
The above assert fails. It seems the second call returns the first assembly even if the two assemblies above have different versions and locations.
The assemblies are not stong-named and can't be signed.
Is there a way to force the framework to load them in the same context and domain?
Use Assembly.LoadFile(path) instead.
From MSDN
The LoadFrom method has the following disadvantages. Consider using Load instead.
If an assembly with the same identity is already loaded, LoadFrom returns the loaded assembly even if a different path was specified.
From CLR developer Suzanne Cook's blog:
If the assembly is not strongly-named, then the version is ignored for binding. But, if it is strongly-named, the entire version in the assembly reference needs to match the found assembly.
yes, you can use Assembly.LoadFile(). http://blogs.msdn.com/b/suzcook/archive/2003/09/19/loadfile-vs-loadfrom.aspx
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With