简体   繁体   中英

Adding Reference causes post-build to fail

I am having trouble adding log4net to my project. 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 ?)

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

Try changing the "Target Framework" (for the Project) to .NET Framework 4 from .NET 4 Client Framework.

Log4Net then works fine.

在此处输入图片说明

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 . Switch to .Net full version . Log4net uses System.Web which is not included in Client Profile.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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