【问题标题】:Dependency reference issues in VS2012 on Windows 8Windows 8 上 VS2012 中的依赖关系参考问题
【发布时间】:2012-11-24 19:10:47
【问题描述】:

我有几个项目的解决方案,其中许多都引用了 Apache 的 log4net。我目前正在尝试仅构建其中一个项目(类库)来解决我遇到的参考问题,但还没有运气。

只有在 Windows 8 上的 VS2012 中构建时才会出现警告和错误,而在 Windows 7 上的 VS2010 中不会出现。

有人知道我该如何解决这个问题吗?这是警告信息;

The primary reference "log4net" could not be resolved because it was built against the ".NETFramework,Version=v4.0.1,Profile=Client" framework. This is a higher version than the currently targeted framework ".NETFramework,Version=v4.0,Profile=Client".

这是错误消息:

The type or namespace name 'log4net' could not be found (are you missing a using directive or an assembly reference?) C:\Users\Rune\Documents\Team Foundation Server\noOdin\Yggdrasil\OdinLib\Common.cs

The type or namespace name 'ILog' could not be found (are you missing a using directive or an assembly reference?) C:\Users\Rune\Documents\Team Foundation Server\noOdin\Yggdrasil\OdinLib\Common.cs

我现在忽略错误,因为它们是 log4net 引用未加载的结果。

引用包含在我的 .csproj 文件中,如下所示:

<Reference Include="log4net"><HintPath>..\..\Dependencies\log4net.dll</HintPath></Reference>

因此,问题确实是我得到的警告,因为它似乎在我的 Dependencies 文件夹中找到了我的 log4net.dll 文件。

任何人都知道我可以如何解决这个问题?

如果您需要更多信息,请务必询问。

【问题讨论】:

  • 您是否尝试过运行 Windows 更新甚至手动安装更新 4.01(参见 support.microsoft.com/kb/2478063)?
  • 您使用的 log4net 的确切版本和风格是什么?网络cp\4.0?
  • 我正在使用 log4net 客户端配置文件库。我现在已将所有项目都设置为需要 .NET 4,但我设置为需要 .NET 4 客户端配置文件的一个控制台应用程序除外。这样做会带回我最初提到的警告,但仅限于这个项目。
  • 更新:在将所有项目的目标框架更改为 .NET 4、删除所有项目的 log4net 引用并再次添加后,我设法构建了它。我注意到在再次添加引用后,它在 .csproj 文件中将 &lt;SpecificVersion&gt;False&lt;/SpecificVersion&gt; 添加到我的 log4net 引用中。我现在什至可以将其改回客户端配置文件,并且构建得很好。
  • 您可以发表您的评论作为对您问题的回答并接受它。这样做有很多好处!

标签: c# .net windows-8 visual-studio-2012 log4net


【解决方案1】:

csproj 文件中缺少 &lt;SpecificVersion&gt;False&lt;/SpecificVersion&gt;,这会强制使用特定版本的 log4net-library。

添加此答案以解决未回答列表中的问题:)

【讨论】:

    猜你喜欢
    • 2015-08-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-05-04
    • 2018-07-05
    • 2017-10-07
    相关资源
    最近更新 更多