I recently needed to include two versions of log4net in one project, both versions were called in by external components, Gentle.net and Nhiberbernate.
To do this you need to add both versions to the GAC.
The gacutil.exe that ships with .NET can be used to add or remove a shared assembly from the GAC.
To add a shared assembly, from the command line enter: gacutil.exe /i myassembly.dll
To remove a shared assembly, from the command line enter: gacutil.exe /u myassembly.dll
Then use a BindingRedirect in the web.config (or app.config)
<runtime>
<assemblybinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentassembly>
<assemblyidentity name="log4net" publickeytoken="b32731d11ce58905">
culture="neutral" />
<bindingredirect oldversion="1.2.0.30714" newversion="1.2.9.0">
</bindingredirect>
</assemblyidentity>
</dependentassembly>
The order of sections in the
web.config is important. If you put your configuration (including
log4net configuration) before the configuration for the component pulling in the newer version, then the logging will work.
Assemblies currently in the GAC are located in the Assembly folder in the Windows directory (usually: C:\WinNT\Assembly)
It's nice to be important...
2 years ago
0 comments:
Post a Comment