How to resolve conflicting assemblies in .Net?

In my web application, I am using NHibernate.dll . It depends on the next build.

'Antlr3.Runtime, Version = 3.1.0.39271, Culture = neutral, PublicKeyToken = 3a9cab8f8d22bfb7'

Now in the same project for another requirement I have to enter Antlr3.StringTemplate.dll . Which has a dependency on another version of the above assembly.

If I use the version of Antlr3.Runtime.dll that satisfies NHibernate , Antlr3.StringTemplate starts complaining and vice versa.

How to resolve this situation?

+6
nhibernate assemblies
source share
4 answers

You can probably use assemblyBinding in your web.config to redirect your latest version to the old version.

Example:

<runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <dependentAssembly> <assemblyIdentity name="NHibernate" publicKeyToken="aa95f207798dfdb4"/> <bindingRedirect oldVersion="2.1.0.4000" newVersion="2.1.2.4000"/> </dependentAssembly> </assemblyBinding> </runtime> 

This happens directly under the <configuration> node in your web.config.

You can read it here: http://msdn.microsoft.com/en-us/library/2fc472t2%28VS.71%29.aspx

+5
source share

The simplest task would be to recompile the same version. Or you can remove the version specification from the link (and set the specific version to false).

+4
source share

We had to do what Jim Lam offers. We created local versions of all our “third-party libraries” (as we called them), targeting strong names and explicit dependencies (compared to what you might get when loading a dll, which depends on another). We made these local assemblies in our repository (Subversion). Then we placed the resulting assemblies in the "Dependencies / lib" folder under the root of each of our projects, which depended on these assemblies. This allowed us to add them as links to VS, using its relative path location capabilities.

+1
source share

I had the same problem.

has the compulsory work done for you?

I tried it like this, but nothing has changed:

 <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <dependentAssembly> <assemblyIdentity name="Antlr3.Runtime" publicKeyToken="3a9cab8f8d22bfb7" culture="neutral" /> <bindingRedirect oldVersion="*" newVersion="3.1.3.6002" /> <publisherPolicy apply="no"/> </dependentAssembly> </assemblyBinding> 

The same error appeared.

So, I decided to go with the decision to add the old version of Antlr3.Runtime assembly to gac. Now it works great.

+1
source share

All Articles