Wednesday, May 15, 2013

Log4net not found

I have a console application. I added log4net as a reference. I included it in my program with the using keyword. I get an error. 

The type or namespace name 'log4net' could not be found (are you missing a using directive or an assembly reference?)

Yes, I really did add it as a reference. Yes, I changed my Target Framework to ".NET Framework 4.5". What now?

Here's the solution. Include System.Web as a reference to your project. It then compiles successfully! Argh!

What is even more aggravating is that it still seems to compile after you remove System.Web! Double argh!!

This is very misleading. And why would a logger need any kind of dependencies is beyond me. 

This kind if thing would never happen in Java. If there was a dependency in one of the libraries it would just throw a runtime exception. Sigh. Oh well.