views:

130

answers:

4

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?

+4  A: 

The simplest thing would be to recompile both against the same version. Or, you could remove the version specification from the reference (and set specific version to false).

Jim Lamb
+1  A: 

We had to do what Jim Lamb suggests. We built local versions of all our "3rd party libraries" (as we dubbed them), targeting strong names and explicit dependencies (versus what you might get when you download a dll that depends on another). We committed these local builds into our repository (Subversion). Then we placed the resulting assemblies in a "Dependencies/lib" folder under the root of each of our projects which depended on those assemblies. This allowed us to add them as VS references using its relative path location capabilities.

soccerdad
+3  A: 

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

jishi
A: 

i had the same problem.

did the bindingredirect work for you?

i have tried it like this, but nothing 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>

Same error appeared.

So i decided to go with the solution of adding the old version Antlr3.Runtime assembly to gac. Now it works perfectly.

memical