views:

34

answers:

1

My application is referencing Microsoft Enterprise library V4.1 while one of the older DLL (external application) requires a reference to Microsoft Enterprise library V2.0. I know for sure that i can register both of these assemblies in the GAC and the application will start reading relevant DLL as required but that is not a solution for us since our security expert is not agreeing upon accepting this solution.

Is there any way using the webconfig where I can specifically specify that the Older DLL use V2.0 while the entire application uses 4.V0.

note : We're using Asp.net visual Studio C#

Help needed desperately ! Thanks

Update :

Tried the solution of using privatePath probing :

    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
        <probing privatePath="bin;ExtDLL"/>
    </assemblyBinding>

My Web folder now has ExtDLL folder which contains V2.0.0.0 Dlls for Microsoft Enterprise library, but i still get the following exception as soon as i call the external DLL's function which is using V2.0.0.0 assembly:

...System.IO.FileLoadException: Could not load file or assembly 'Microsoft.Practices.EnterpriseLibrary.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
A: 

I was unable to be able to load both versions of Enterprise Library using probing/privatePath or codebase configuration.

The only way I was able to get it to work was using custom resolving of assembly loads..

I placed the 2.0 assemblies in the application bin directory. Then I placed the 4.1 assemblies in a directory called EL41 under bin (bin\EL41). I then added custom event handler to try to resolve the assembly by adding

AppDomain.CurrentDomain.AssemblyResolve += newResolveEventHandler(MyResolveEventHandler);

to startup code and then creating the MyResolveEventHandler

private static Assembly MyResolveEventHandler(object sender, ResolveEventArgs args)
{
    string[] assemblyInfo = args.Name.Split(',');
    return Assembly.LoadFrom(@"file:///C:/Documents and Settings/My Documents/Visual Studio 2008/Projects/App/bin/EL41/" + assemblyInfo[0] + ".dll");
}

This definitely will work. You could place the path in configuration to avoid hard coding the location but it still feels wrong to me. I wonder if there is a less intrusive way to do what you want.

Tuzo