I have a Wpf.net 4.0 C # project that I am trying to port using Log4Net to use NLog as the registration library for the Common.Logging Façade object. I expected this to be an easy task, but you know what they say: “Nothing is ever easy.
I used NuGet for:
- Download NLog version 2.0.1.2.
- Download Common.Logging.NLog version 2.0.0.
- Download Common.Logging.NLog20 in version 2.1.2.
- The general journal has been updated from version 2.0.0 to version 2.1.2 using NuGet.
In the app.config file, I have:
<common> <logging> <factoryAdapter type="Common.Logging.NLog.NLogLoggerFactoryAdapter, Common.Logging.NLog"> <arg key="configType" value="FILE" /> <arg key="configFile" value="~/NLog.config" /> </factoryAdapter> </logging> </common>
... and ...
<dependentAssembly> <assemblyIdentity name="NLog" publicKeyToken="5120e14c03d0593c" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-2.0.1.0" newVersion="2.0.1.0" /> </dependentAssembly>
When I launch the application, I get an error
'Casting the constructor to the type "NameSpace.Shell.AppBootstrapper", which matches the specified binding constraints, throws an exception. "Line number" 8 "and line position" 18 ".
Internal exception:
{"Cannot load one or more of the requested types. LoaderExceptions for more information." }
Loader exception fixed, there is only one:
{"Failed to load type NLog.TargetWithLayout from the NLog assembly, Version = 2.0.1.0, Culture = neutral, PublicKeyToken = 5120e14c03d0593c.": "NLog.TargetWithLayout"}
Can anyone solve this problem or work NLog working with Common.Logging to get NLog working with Common.Logging ?
In the interest of not sending a long question, I did not include the NLog.config file, but I could if it were beneficial.
c # nlog common.logging
Klee
source share