C# 使用nLog和公共日志记录的XAML设计模式中出错
我得到以下错误:C# 使用nLog和公共日志记录的XAML设计模式中出错,c#,visual-studio-2012,nlog,common.logging,C#,Visual Studio 2012,Nlog,Common.logging,我得到以下错误: --------------------------- 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=
---------------------------
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
编辑器/选择器时,任何窗口/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>
我也遇到了同样的问题,我通过引用Common.Logging在模块内部解决了这个问题,该模块存在视图/设计器问题。看起来我在命名空间定义中引用的东西依赖于该项目的Common.Logging。i、 我的模块依赖于另一个使用公共的自定义类库
这个问题以一种奇怪的方式表现出来,设计师发出了一个无用的错误,但添加了引用修复了它。你能给我们看一下你的NLog.config文件吗?有人知道是什么导致了这个问题吗?我还需要一段时间才能再次处理这个项目(它运行得很好,而不是错误)来验证,但我会假设您在导致问题的原因上是正确的。非常感谢!:)很抱歉,我说的不完全正确,起初它似乎有帮助,但后来问题又出现了。我们强烈怀疑它与设计人员实例化的类中的静态初始化器有关,因此主要怀疑对象是LogManager.GetCurrentClassLogger(),因为这看起来在进行一些令人讨厌的反射。这个问题现在对我们来说是次要的,尽管随着我们转向VS2012,设计师变得更加健壮,所以它不再爆炸。它还有一些更有意义的错误,所以我将在时间允许的情况下进一步深入研究。同时,我们使用GetLogger()来代替。