MiloszKrajewski/LibZ

System.IO.FileNotFoundException if the version is different

Opened this issue · 1 comments

I have a project with old dependencies and I can not recompile them. Main exe depends on RestSharp and dependency A. Dependency A also depends on RestSharp, but different version.
"Out of the box" the solution doesn't work, I receive this:

  System.IO.FileNotFoundException: Could not load file or assembly 'RestSharp, Version=105.1.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.

I went through the source code and saw that the full name is taken for hashing. While debugging I placed the same resource twice with different hashes (different names, because of the version) and worked. However that is definitely not the solution ;)
I can not put an assembly redirect, since RestSharp is not signed.

I have a a 100% reproducable code here

git clone https://github.com/derwasp/LibZ.Repro.git
cd LibZ.Repro
nuget restore
build

This should give you a crash.

Is there a "switch" for this to magically work?

I have the same issue, when two dlls have dependencies on different versions. It would be nice if you only take the name and not the version into consideration for resolving. Eventually via a flag?