Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to resolve conflicting assemblies in .Net?

In my web application I am using NHibernate.dll. This has a dependency on folowing assembly.

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

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

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

How to resolve a situation like this?

like image 893
Amitabh Avatar asked Jun 15 '10 16:06

Amitabh


People also ask

Where are the .NET framework assemblies stored?

NET Framework, the default location is %windir%\assembly.

What are assemblies explain the working and role of assemblies in net?

An assembly is a collection of types and resources that are built to work together and form a logical unit of functionality. Assemblies take the form of executable (.exe) or dynamic link library (. dll) files, and are the building blocks of . NET applications.

Can not load file or assembly?

Http 5.2. 0.0? In summary if you get the "Could not load file or assembly error", this means that either your projects or their references were built with a reference to a specific version of an assembly which is missing from your bin directory or GAC.


1 Answers

You could probably use assemblyBinding in your web.config to redirect your newest 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 goes directly under the <configuration> node in your web.config.

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

like image 145
jishi Avatar answered Sep 21 '22 23:09

jishi