Question

I am getting the following error:

---------------------------
Microsoft Visual Studio
---------------------------
Could not load the assembly Common.Logging.NLog because the following errors occurred:

Could not load type 'NLog.TargetWithLayout' from assembly 'NLog, Version=2.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c'.
---------------------------
OK   
---------------------------

When I try to use the DataContext editor / selector any the Window/Usercontrol properties. I pulled both assemblies down from NuGet

NLog Config:

<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      autoReload="true"
      throwExceptions="false">

    <!-- 
  See http://nlog-project.org/wiki/Configuration_file 
  for information on customizing logging rules and outputs.
   -->
    <variable name="appName" value="APPLICATION" />
    <targets async="true">
        <target xsi:type="File"
                name="default"
                fileName="${specialfolder:ApplicationData}/APPLICATION/logs/${shortdate}.log"
                layout="${longdate} | ${uppercase:${level}} | ${message}${onexception:${newline}EXCEPTION\: ${exception:format=ToString}}"
                keepFileOpen="false"  />
        <target xsi:type="File"
                name="debug"
                fileName="${specialfolder:ApplicationData}/APPLICATION/logs/${shortdate}_debug.log"
                layout="${longdate} | ${uppercase:${level}} | ${message}${onexception:${newline}EXCEPTION\: ${exception:format=ToString}}"
                keepFileOpen="false"  />
        <target xsi:type="EventLog"
                name="eventlog"
                source="${appName}"
                layout="${message}${newline}${exception:format=ToString}" />
    </targets>

    <rules>
        <logger name="*" writeTo="default" minlevel="Info" />
        <logger name="*" writeTo="debug" minlevel="Trace" maxlevel="Debug" />
        <logger name="*" writeTo="eventlog" minlevel="Error" />
    </rules>
</nlog>
Was it helpful?

Solution

I had the same problem and I fixed it by referencing Common.Logging inside the module which had the view/designer problem. It looks like something I was referencing in my namespace definitions had a dependency on Common.Logging being findable for that project. i.e. my module depended on another custom class library that used common.

Strange way for this problem to manifest, and useless error from the designer, but adding the refence fixed it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top