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 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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With