views:

63

answers:

2

I'm using NHibernate 2.1.2.400 that is referencing log4net 1.2.10.0. In the same project, I also use the simply accounting SDK, sadly it is still using log4net 1.2.9.0.

So I can get NHibernate to work if I reference log4net 1.2.10.0 but the simplySDK don't work. And vice versa...

I'm guessing most of the problems come from the fact that log4net has changed it's assembly key. I Tried using a binding redirection without success: the 2 dlls do not have the same key.

I'm considering recompiling NHibernate to use log4net 1.2.9.0 but it seems like the wrong thing to do and my feeling is that Simply Accounting won't be very quick to update their SDK to use log4net 1.2.10.0.

I'm using .net 4.0

Could using a probing private path in the app.config file help?

What is the best way to handle this? Is it possible to resolve at all?

+1  A: 

If binding redirection doesn't work and the simply accounting SDK is closed source, a possible solution is recompiling NHibernate to use log4net 1.2.9.0.

Diego Mijelshon
That would work, but having to build a special version of nhibernate would be harder to support down the line... thanks.
Joel Gauvreau
+2  A: 

I found the solution by using this answer to a similar question

You create 2 folder in your project one for each version of log4net. You place each log4net.dll in its corresponding folder by adding an the file to the solution (not with add reference). You can set the copy to output directory property to copy always so that it is automatically copied to the output folder when you build.

Then you modifiy the app.config file by adding something like this:

<configuration>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="log4net" publicKeyToken="681549d62126b7b8" />
        <codeBase version="1.2.9.0" href="log4netv1.2.9.0\log4net.dll" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="log4net" publicKeyToken="1b44e1d426115821" />
          <codeBase version="1.2.10.0" href="log4netv1.2.10.0\log4net.dll" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>

you can get the public key token of an assembly by using sn -T [assemblyName]

Joel Gauvreau
This seems to work for me as well. I removed log4net from my References list for the project where the conflict was occuring. Also, since log4net.dll is not in my bin folders, my href paths looked more like "..\..\..\..\Lib\NHibernate-2.0.1.GA\log4net.dll"--just a relative path to where log4net will be on every dev's machine with our build system.
apollodude217