1
votes

I am upgrading a solution to Visual Studio 2012 (and 2013, but that's a side issue)

I am encountering the following error (many times) when compiling the test projects:

Error 345 The type 'System.Action' exists in both 'c:\Users\neil\Documents\Visual Studio 2013\Referenced Assemblies\Third Party Dlls\Moq\Moq.dll' and 'c:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.0\System.Core.dll' .....

We are using Moq 4.0000, and the solution is using .Net 3.5 in all projects. It looks like the .Net framework now has a System.Func<....> implementation (previously only defined in Moq?) Oddly we haven't had this problem with VS2008, also using .Net 3.5.

Does anyone know how to resolve this?

1
Are sure you are referencing the Moq assembly built for .NET 3.5? - Patrick Quirk
See this question, possible duplicate. Just not sure why a new Visual Studio version would throw this error and the older one wouldn't. - Patrick Quirk
Probably, but the latest one available is dated 2011, which precedes VS2012 anyway. - haughtonomous
An extra puzzle is that in VS2008 and VS2012 all projects are set to use .Net 3.5. So why the clash in VS2012 when VS2008 happily compiles? - haughtonomous

1 Answers

0
votes

Action and Func with many parameters were added only with .NET 4.0. Was it initially a .NET 2.0 project? In that case, you can try to remove the System.Core.dll from the references and try to see if the project compiles. Despite the name, it is unessential and was added only with .NET 3.5. The cleanest solution would be to upadate your library, Moq, with an updated one that fixes the clash in .NET 4.0. If that is not an option, follow Pratick advice to use assembly extern aliases.