Well, you have already found the answer. Log4net has a dependency on System.Web.dll, an assembly not available in the client profile. The likely main reason for this dependency is the log4net.Appender.AspNetTraceAppender class, it uses the HttpContext class and requires System.Web.
Right now, this is what you need to know from the library documentation, or finding it difficult. The building generates a warning, but this is only a warning, not an error, it is easy to skip:
C: \ Windows \ Microsoft.NET \ Framework \ v4.0.30319 \ Microsoft.Common.targets (1360.9): warning MSB3253: assembly reference "C: \ projects \ WindowsFormsApplication2 \ ClassLibrary1 \ bin \ Debug \ ClassLibrary1.dll" cannot be resolved because it has a dependency on "System.Web, Version = 4.0.0.0, Culture = neutral, PublicKeyToken = b03f5f7f11d50a3a", which is not in the target environment ".NETFramework, Version = v4.0", Profile = Client ". Remove assembly references not in the target structure or do not consider redirecting your project.
The following are errors from any statements in your code that attempt to reference classes in an assembly containing a link to log4net.
C: \ projects \ WindowsFormsApplication2 \ WindowsFormsApplication2 \ Form1.cs (12,9): error CS0246: the name of the type or namespace 'ClassLibrary1' could not be found (do you miss the using directive or assembly references?)
You will not miss either, and there can be many mistakes if you do not create incrementally when writing code. You focus on errors and donβt understand that warning is a true source of errors. Another nasty trap is that IntelliSense is happy at first, it solves the build problem correctly. There is some evidence that the warning is not always generated, simply because many programmers do not seem to notice it. I have not yet found a scenario where this is the case. Not sure.
source share