开发者

Unit testing 3.5 project in VS2010 yields CS1685 warnings

开发者 https://www.devze.com 2023-02-15 03:35 出处:网络
I have a project in development that targets .NET 3.5.I have no choice about this as the corporate big-wigs will not let us target 4.0.I\'ve added a new Test Project to the solution in Visual Studio 2

I have a project in development that targets .NET 3.5. I have no choice about this as the corporate big-wigs will not let us target 4.0. I've added a new Test Project to the solution in Visual Studio 2010. I see that I can only target the 4.0 Framework from the test project (which is okay because it's not deployed).

Everything is great except that I get compiler warnings from my test开发者_Go百科 projects:

warning CS1685: The predefined type 'System.Action' is defined in multiple assemblies in the global alias; using definition from 'c:\Program Files\Reference Assemblies\Microsoft\Framework.NETFramework\v4.0\System.Core.dll'

I removed the reference to System.Core from the test project and the warning is still occurring. I can only assume it is because the project I am testing is targeting 3.5 so something is getting crossed up. Is there a CLEAN way to eliminate this warning until we are given approval to target 4.0 in our apps?


It sounds like you are using MSTest as your unit testing framework. If so the problem is that MSTest does not support down targeting in Visual Studio 2010. This means it will load the 4.0 version of the .Net assemblies even if the project your testing is targeting 3.5. This causes the conflicts you are seeing due to the multiple versions of System.Core which get loaded in this scenario.

Sadly there is no way to work around this problem other than to upgrade your project to 4.0.

0

精彩评论

暂无评论...
验证码 换一张
取 消