Visual Studio 2010 Windows Application and Log4Net

On June 13, 2011, in Programming, by Dirk Strauss

I just wanted to post a quick note here regarding a build error I got for the Log4Net Logging Service and Visual Studio 2010. I added the Log4Net DLL and some logging to my application, but on the Build, I received the following Warning:

The referenced assembly “log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=1b44e1d426115821, processorArchitecture=MSIL” could not be resolved because it has a dependency on “System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a” which is not in the currently targeted framework “.NETFramework,Version=v4.0,Profile=Client”. Please remove references to assemblies not in the targeted framework or consider retargeting your project

This simply means that the Log4Net DLL relies on some classes in System.Web and isn’t included in the current selection of your .NET Framework. This is because you can choose two types of .NET Framework 4. These are the Client Profile and the Full framework. When do I use NET4 Client Profile and when do I use NET4 Full Framework I hear you say? See here for an article.

Meanwhile, go to your Project Properties (Visual Studio Menu bar: Project ->[ProjectName] Properties…). You should see that the framework is selected to .NET Framework 4 Client Profile. Change this to the .NET Framework 4 and save. Rebuild your project and you’ll be good to go.

Correct Framework

 

 

 

Tagged with:  

2 Responses to Visual Studio 2010 Windows Application and Log4Net

  1. Nitci says:

    Thanks a lot.. :)
    saved time and efforts..

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>