0

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.

gwin003
  • 7,432
  • 5
  • 38
  • 59
  • Does the string $(SolutionDir)3rdParty have a missing "\"? –  Sep 10 '13 at 11:49
  • @wonko79 No, because the dll is being copied to my output directory just fine. – gwin003 Sep 10 '13 at 11:53
  • When you have referenced log4net in you project why is setting CopyLocal to true for this reference not enough? –  Sep 10 '13 at 11:58
  • @wonko79 No idea why its not working, no matter what I set `CopyLocal` to, it still fails. – gwin003 Sep 10 '13 at 11:59
  • I meant CopyLocal=true and remove copying in postbuild –  Sep 10 '13 at 12:38
  • @wonko79 Tried it, still not working. I have the copying in the post build removed because its not helping at all. – gwin003 Sep 10 '13 at 12:39
  • Seems strange to be compiling something in your PostBuild event, but I'm guessing you need to change this to reference log4net.dll (ie add /reference:log4net.dll) – sgmoore Sep 10 '13 at 17:18

2 Answers2

1

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

Log4Net then works fine.

enter image description here

EDIT:

May be there's some problem with referencing! Try to add the reference correctly.

0

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.

Kurubaran
  • 8,696
  • 5
  • 43
  • 65