I've got a Wpf .net 4.0 C# project that I am attempting to migrate from using Log4Net to using NLog as the logging library behind the Common.Logging Façade. I had expected this to be an easy task, but you know what they say, Nothing is ever easy.
I have used NuGet to:
- Download NLog at version 2.0.1.2.
- Download Common.Logging.NLog at version 2.0.0.
- Download Common.Logging.NLog20 at version 2.1.2.
- Updated Common Logging 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 run the application I get an error stating
'The invocation of the constructor on type 'NameSpace.Shell.AppBootstrapper' that matches the specified binding constraints threw an exception.' Line number '8' and line position '18'.
The inner exception is:
{"Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information."}
Said Loader exception, there is one only, is:
{"Could not load type 'NLog.TargetWithLayout' from assembly 'NLog, Version=2.0.1.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c'.":"NLog.TargetWithLayout"}
Has anyone overcome this problem or have a work around to get NLog working with Common.Logging
?
In the interests on not posting to long of a question I have not included the NLog.config
file but I can if it would be beneficial.