问题
I'm currently trying to use Pex and Moles with a SharePoint 2010 solution that's written in .NET 3.5. When adding a test project (by using Pex -> Create parameterized tests) everything seems to work OK. However, when I try to compile I end up with a massive list of errors (missing namespaces and such) and warnings regarding referenced assemblies not being able to be resolved (such as System.Web which under .NET 4 is no single DLL anymore).
This is due to the projects under test is .NET 3.5 and the Pex test project is .NET 4.0 as far as I understand it, but is it possible to make this combination work at all?
回答1:
If you change the project Target Framework to ".Net Framework 3.5" and then open the project AssemblyInfo.cs file and comment out the following line:
[assembly: SecurityRules(SecurityRuleSet.Level1)]
the project should build. How this affects PEX and its "Explorations" I am not sure. I hope this gets you a little further down the road.
回答2:
The answer is here: http://msdn.microsoft.com/en-us/library/system.reflection.assembly.securityruleset.aspx
"By default, assemblies that you compile with the .NET Framework version 4 have level 2 transparency, although you can explicitly make them level 1 instead.Assemblies that were compiled with earlier versions of the .NET Framework have level 1 transparency"
来源:https://stackoverflow.com/questions/6816357/running-pex-with-net-3-5-projects