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

冷暖自知 提交于 2020-02-27 02:55:19

今天碰到一个问题,其实之前也有碰到过。

在visual studio 2010创建控制台程序的时候(其它项目还不知道会不会有同样的问题)。

添加log4net.dll引用,随便写点代码,如:

 

static void Main(string[] args)        {            log4net.Config.XmlConfigurator.Configure();        }    }

编译,通不过,

Error 1 The type or namespace name 'log4net' could not be found (are you missing a using directive or an assembly reference?) C:\Users\Joe\Desktop\sample\sample\ConsoleApplication1\Program.cs 5 7 ConsoleApplication1
奇怪啊,怎么就报错了啊。重新打开visual studio 2010,新建项目,重新添加应用,问题照旧。

这是发现一个提示:

Warning 1 The referenced assembly "log4net" 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. ConsoleApplication1
问题出来,打开项目属性,恶作剧原来在此啊,

晕啊,自作多情,干嘛新建项目的时候要自动选择.net framework 4 client profile。

重新选择.net framework 4.问题解决。

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!