Aug 06, 2008 / .net
Using two .NET assemblies with the same name but different versions

I recently worked on a solution where we needed to use two versions of the same 3rd party DLL within one web app. This was because we were using some new assemblies of a 3rd party library combined with some old assemblies, and they both referenced an assembly with the same name but different versions.

The error we were getting was:

System.IO.FileNotFoundException: File or assembly name Syncfusion.Core, or one of its dependencies, was not found.

Getting around this was tricky, mainly because I have shallow knowledge in this area! Ultimately the only way I could find to make it work was to put the assembly in another folder, and add an assemblyIdentity option to web.config.

        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">        

So, in the filesystem you end up with :

/bin/Syncfusion.Core.DLL -> Syncfusion.Core, Version=, Culture=neutral, PublicKeyToken=632609b4d040f6b4
/bin/dependentAssemblies/Syncfusion.Core.DLL -> Syncfusion.Core, Version=4.401.0.51, Culture=neutral, PublicKeyToken=632609b4d040f6b4

Is there a better way?

I tried getting .NET (1.1) to probe a new folder in the application directory like this:

<probing privatePath="bin/dependentAssemblies" />

But that didn't work, when the runtime tryied to find the assemblies, I could see it going through /bin folder and the GAC, but not the privatePath for some reason.

I also tried adding both versions of the assembly directly as follows, and renaming the DLL and dropping it alongside the other in the bin folder.

    <add assembly="Syncfusion.Core, Version=, Culture=neutral, PublicKeyToken=632609b4d040f6b4"/>
    <add assembly="Syncfusion.Core, Version=4.401.0.51, Culture=neutral, PublicKeyToken=632609b4d040f6b4"/>         

But no luck there either. I think it was down to .NET not being happy with me renaming DLLs that are strongly named/signed (which would make sense).

Anyway, hope this helps someone. If anyone knows some good resources for getting your head around this stuff, let me know.

Here's some I found so far:

MSDN, MSDN, CodingHorror,Some forum

You may also like...