Somehow I've been lucky and never had to deal with this problem, even though I think it's a common one:
I've got a web project, let's call it SomeProject
. SomeProject
has a reference to a 3rd party library, let's call it SomeThirdParty
, version 1.0. SomeProject
also has a reference to a home-grown class library, let's call it SomeLibrary
. SomeLibrary
also has a reference to SomeThirdParty
, but a different version (let's say 2.0).
Version 1.0 and 2.0 of SomeThirdParty
share most of the same signatures, but are different implementations. I need SomeProject
to use the 1.0 implementation, and SomeLibrary
to use the 2.0 implementation if possible.
I compile SomeProject
using its reference to log4net. The DLL that ends up in the bin directory is the one that SomeProject
references. At runtime, when code from SomeLibrary
runs, it attempts to execute the code from version 2.0 of SomeThirdParty
, and of course fails, throwing a FileLoadException: Could not load file or assembly '
SomeThirdParty, Version=2.0.0.0, Culture=[etc.]' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference.
Obviously I could upgrade SomeProject
to the newer DLL or downgrade SomeLibrary
to the older DLL, but it wouldn't be ideal for many reasons.
I think the right answer involves installing SomeThirdParty in the GAC, but I'm not sure exactly how I'd go about doing this, and how it would affect other developers and servers.
Any suggestions you may have are appreciated.
Thanks for the help.
Putting both versions of SomeThirdParty into GAC should do what you want. Use gacutil utility or Start->Run->assembly then drag-n-drop.
From my answer earlier: https://stackoverflow.com/a/19576769/2367343
I ran into this yesterday for visual studio web developer using Oracle.DataAccess.dll.
My solution,
right click your project (*.csproj) and edit it.
Right underneath:
<PropertyGroup>
Place
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
Then rebuild your solution. You must separate the two version dlls into two different directories in your project when including them (required).
I did
ora11 >> Oracle.DataAccess.dll (Version 11)
ora9 >> Oracle.DataAccess.dll (Version 9)
Doing this allows your IDE to use both versions of DLLs.
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