0

我收到以下错误:

---------------------------
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   
---------------------------

当我尝试使用DataContext编辑器/选择器时,任何 Window/Usercontrol 属性。我从 NuGet 拉下两个程序集

NLog 配置:

<?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>
4

1 回答 1

1

我遇到了同样的问题,我通过在有视图/设计器问题的模块中引用 Common.Logging 来修复它。看起来我在命名空间定义中引用的东西依赖于 Common.Logging 可用于该项目。即我的模块依赖于另一个使用通用的自定义类库。

这个问题出现的奇怪方式,以及设计师的无用错误,但添加引用修复了它。

于 2013-02-01T15:57:57.487 回答