AssemblyResolve is trying to get a different version than the one specified in Assembly.Load

68 Views Asked by At

I've got a custom assembly-resolving code that is acting up. Initially I'm running a piece of code that attempts to detect all assemblies referenced by a given C# library and this seems to return correct results. Then I'm trying to load those referenced libraries to detect other needed libraries (essentially I'm trying to build a list of ALL libraries that might be needed by a given DLL).

In this particular instance I've got an Assembly object reference to SomeAssembly.dll, version 1 (which appears to be the correct version). However, when running Assembly.Load on this reference I enter the AssemblyResolve event with ResolveEventArgs pointing to SomeAssembly, version 2. Attempting to load the "expected" version (i.e. version 1) results in a failure.

a) Why would C# change the version like this?
b) Can I "override" which version I want to load in the AssemblyResolve event?

1

There are 1 best solutions below

0
MBender On BEST ANSWER

Well I feel silly...

I've had some <bindingRedirect> in my App.config...