Search code examples
c#assemblybindingassemblyversionsprobing

Executing application which references multiple different versions of an assembly


I am creating a test project to compare performance of EF4 to EF5 and i want to be able to have a separate dll for each EF version which references the correct EF version, but i want to be able to launch the tests from a single executable, at the moment this will mean i have 2 copies of the EF dll sitting in my exe directory which is no good.

I understand that you can somehow have multiple version of a dll using something called probing but i'm not too sure how to implement it, does anyone have a code example of this? or is there a better way


Solution

  • I solved this by using the following in my app.config

    <runtime>
        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
          <dependentAssembly>
            <assemblyIdentity name="EntityFramework" version="5.0.0.0"
                              publicKeyToken="b77a5c561934e089"
                              culture="neutral" />
            <codeBase version="5.0.0.0" href="..\..\..\packages\EntityFramework.5.0.0-beta1\lib\net45\EntityFramework.dll" />
          </dependentAssembly>
          <dependentAssembly>
            <assemblyIdentity name="EntityFramework" version="4.1.0.0"
                              publicKeyToken="b77a5c561934e089"
                              culture="neutral" />
            <codeBase version="4.1.0.0" href="..\..\..\packages\EntityFramework.4.1.10331.0\lib\EntityFramework.dll" />
          </dependentAssembly>
        </assemblyBinding>
      </runtime>