简体   繁体   English

添加引用会导致构建后失败

[英]Adding Reference causes post-build to fail

I am having trouble adding log4net to my project. 我在将log4net添加到我的项目时遇到问题。 I added the reference and set everything up ok, but the build is failing. 我添加了参考,并一切正常,但构建失败。 One of the error messages is complaining about the post-build failing, and the other error messages are saying 错误消息之一是抱怨构建后失败,其他错误消息是说

The type or namespace name 'log4net' could not be found (are you missing blah blah ?) 找不到类型或名称空间名称“ log4net”(您是否缺少等等 ?)

But whenever I remove the post-build event, the project builds just fine. 但是,每当我删除构建后事件时,项目的构建就可以了。 How can I fix my post-build event so I can reference log4net? 如何解决构建后事件,以便可以引用log4net? Here is my current post-build (formatted to fit on page w/o scrolling): 这是我当前的后期构建(格式适合不带滚动的页面):

copy /y "$(SolutionDir)3rdParty\log4net.dll" "$(TargetDir)"

c:\Windows\Microsoft.NET\Framework\v4.0.30319\csc.exe /target:module 
 /r:"$(SolutionDir)2ndParty\PrintManager.dll" 
 /out:$(TargetDir)PrintModule.netmodule 
 $(ProjectDir)PrinterManaged.cs

My project Target Framework is already set to .NET Framework 4 . 我的项目Target Framework已经设置为.NET Framework 4

Try changing the "Target Framework" (for the Project) to .NET Framework 4 from .NET 4 Client Framework. 尝试将“目标框架”(针对项目)从.NET 4 Client Framework更改为.NET Framework 4。

Log4Net then works fine. Log4Net然后工作正常。

在此处输入图片说明

EDIT: 编辑:

May be there's some problem with referencing! 引用可能存在一些问题! Try to add the reference correctly. 尝试正确添加参考。

I guess your project is built in .Net Client Profile . 我想您的项目是建立在.Net Client Profile Switch to .Net full version . 切换到.Net full version Log4net uses System.Web which is not included in Client Profile. Log4net使用System.Web,它不包含在客户端配置文件中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM