【问题标题】:Common.Logging.Nlog is not copied to /testresults/.../out folderCommon.Logging.Nlog 未复制到 /testresults/.../out 文件夹
【发布时间】:2013-06-08 14:03:12
【问题描述】:

我正在开发一个通过 common.logging、common.logging.nlog 和 nlog 进行日志记录的应用程序。日志在应用程序中工作正常 - web.config 没问题。

但是 - 当我将日志记录配置应用到我的测试项目的 App.config 时,日志记录不起作用,说明:

Unable to create type 'Common.Logging.NLog.NLogLoggerFactoryAdapter, Common.Logging.NLog'

Innerexception 是“无法从文件加载程序集”。

这是包裹:

<?xml version="1.0" encoding="utf-8"?>
<packages>
  <package id="Common.Logging" version="2.1.2" targetFramework="net40" />
  <package id="Common.Logging.NLog" version="2.0.0" targetFramework="net40" />
  <package id="EntityFramework" version="5.0.0" targetFramework="net45" />
  <package id="FakeDbSet" version="1.4.0.0" targetFramework="net45" />
  <package id="FluentAssertions" version="2.0.1" targetFramework="net40" />
  <package id="Moq" version="4.0.10827" targetFramework="net45" />
  <package id="NLog" version="2.0.1.2" targetFramework="net40" />
</packages>

编辑

这是项目文件

    <Reference Include="Common.Logging, Version=2.1.2.0, Culture=neutral, PublicKeyToken=af08829b84f0328e, processorArchitecture=MSIL">
      <SpecificVersion>False</SpecificVersion>
      <HintPath>..\packages\Common.Logging.2.1.2\lib\net40\Common.Logging.dll</HintPath>
      <Private>True</Private>
    </Reference>
    <Reference Include="Common.Logging.NLog">


<HintPath>..\packages\Common.Logging.NLog.2.0.0\lib\2.0\Common.Logging.NLog.dll</HintPath>
  <Private>True</Private>
</Reference>
    <Reference Include="NLog">
  <HintPath>..\packages\NLog.2.0.1.2\lib\net40\NLog.dll</HintPath>
  <Private>True</Private>
</Reference>

如果我转到 /testresults/.../out 文件夹 - 那里有 Common.Logging,但没有其他两个必需的库( common.logging.nlog 和 nlog )。它们都在项目中被引用,并且将“本地复制”设置为 true。

有什么线索吗?

【问题讨论】:

  • 看起来非常相似 - 谢谢,但是,快速修复对我来说还没有奏效。
  • 还在同一线程中寻找另一个快速而肮脏的修复方法:在您的代码中使用一个明确使用库的虚拟方法。
  • 也试过了——对我没用。 [AssemblyInitialize] public static void InitAssembly() { var classLogger = Common.Logging.LogManager.GetCurrentClassLogger(); var currentClassLogger = NLog.LogManager.GetCurrentClassLogger(); classLogger.Info("test"); currentClassLogger.Info("test"); }
  • 抱歉 - 这对我有用 - 我也必须直接访问 Common.Logging.Nlog。谢谢!

标签: c# visual-studio-2012 mstest common.logging


【解决方案1】:

这是 VS2012 中的一个错误 - @jbl 帮助了我 - 使用此链接: stackoverflow.com/a/8213977/1236044

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-03-12
    • 1970-01-01
    • 1970-01-01
    • 2016-12-31
    • 1970-01-01
    • 2015-09-01
    • 1970-01-01
    相关资源
    最近更新 更多