Log4Net、System.Web.dll 与.Net Framework 4 Client Profile

这两天遇到一个很奇怪的问题。在用VS2010开发程序是,一个Common dll调用了Log4Net。而这个Dll本身做UnitTest没有问题。但是另外一个Office Addin Project无法调用Common dll,Add reference之后在namespace里面根本找不到。仔细查看Build Output发现有个Warning。(Visual Studio有个问题,优先显示Build Error,导致我一直以为Common dll里面有代码写错了,查了很久Sad smile…)

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".

简单来说,就是调用System.Web.dll ,而这个dll在目标的Framework里面没有(被微软干掉了?),仔细检查之后发现Log4net调用了System.Web.dll。但为什么System.Web.dll 会消失呢?微软应该不会做这么大的改动。Google之后发现,问题就在这里:

1

VS2010对于非Web程序,默认采用了Client Profile,并对桌面程序作了优化,其中之一就是移除了一些不用的framework component。我切换到完整版本的.Net Framework 4之后,就一切正查了。关于Client Profile的详细内容,可以看这里 .NET Framework Client Profile

posted @ 2010-12-10 14:47  Justin Zhang  阅读(1160)  评论(2编辑  收藏  举报