Answered by:
TDD with POS for .Net and VS 2010/4.0 (CAS Policy Error)

Question
-
Hi,
I am working on creating some unit tests that test code using POS for .Net. The problem I am having is that I can not get past the "This method explicitly uses CAS policy, which has been obsoleted by the .NET Framework" error that you get when using 4.0. I tried enabling NetFx40_LegacySecurityPolicy in the app.config in the test project but it did not fix the problem. Below is a simple solution that replicates the problem. This is with VS2010 .Net 4.0.
Thanks
Download:
http://rapidshare.com/files/391493582/POSForNetTDD.zip.html
Full error for SEO:
This method explicitly uses CAS policy, which has been obsoleted by the .NET Framework. In order to enable CAS policy for compatibility reasons, please use the NetFx40_LegacySecurityPolicy configuration switch. Please see http://go.microsoft.com/fwlink/?LinkID=155570 for more information.
* Note: I have no formal CS education, so take all advice with caution :)Tuesday, May 25, 2010 5:34 PM
Answers
-
Problem solved, as per Edwer Fang in the above link:
I have found that all test assemblies are now executed in either the QTAgent32.exe or the QTAgent.exe process in VS2010. So you need to modify either of corresponding configure files depend on your MahineOS and Host Process Platform Flag.(See here: http://blogs.msdn.com/b/lkruger/archive/2009/06/08/visual-studio-team-test-load-agent-goes-64-bit.aspx)
The two configure files(QTAgent.exe.config and QTAgent32.exe.config) should be located at “%ProgramFiles%\Microsoft Visual Studio 10.0\Common7\IDE”. If you have changed the installation directory of the product, you need to replace it appropriately here too. You can add the element to these two configuration files.
* Note: I have no formal CS education, so take all advice with caution :)- Marked as answer by EisenB Tuesday, June 1, 2010 1:58 PM
Tuesday, June 1, 2010 1:58 PM
All replies
-
Hi,
You *may* need to edit the .confg file for the IDE (devenv.exe.config, somewhere under program files\microsoft visual studio 10.0\common7\ide probably) so it also includes the legacy cas switch.
Try that and let us know if it works.
Tuesday, May 25, 2010 9:19 PMAnswerer -
No luck, I tried it and when I go to run the test I get this in the output window and the test is not run:
Error loading C:\Users\escherrer\documents\visual studio 2010\Projects\POSForNetTDD\POSForNetTDD\bin\Debug\POSForNetTDD.dll: The security state of an AppDomain was modified by an AppDomainManager configured with the NoSecurityChanges flag.
Thanks for the suggestion though, I really thought it was going to work.
* Note: I have no formal CS education, so take all advice with caution :)Wednesday, May 26, 2010 1:59 PM -
I also just tried putting it in msbuild.exe.config but that did not work either.
* Note: I have no formal CS education, so take all advice with caution :)Wednesday, May 26, 2010 2:04 PM -
Sorry, now I'm really out of ideas.
Perhaps someone else can help...
Wednesday, May 26, 2010 9:34 PMAnswerer -
No problem, I also have a thread open in the testing forum - perhaps they may know how to get past this:
* Note: I have no formal CS education, so take all advice with caution :)Thursday, May 27, 2010 1:43 PM -
Problem solved, as per Edwer Fang in the above link:
I have found that all test assemblies are now executed in either the QTAgent32.exe or the QTAgent.exe process in VS2010. So you need to modify either of corresponding configure files depend on your MahineOS and Host Process Platform Flag.(See here: http://blogs.msdn.com/b/lkruger/archive/2009/06/08/visual-studio-team-test-load-agent-goes-64-bit.aspx)
The two configure files(QTAgent.exe.config and QTAgent32.exe.config) should be located at “%ProgramFiles%\Microsoft Visual Studio 10.0\Common7\IDE”. If you have changed the installation directory of the product, you need to replace it appropriately here too. You can add the element to these two configuration files.
* Note: I have no formal CS education, so take all advice with caution :)- Marked as answer by EisenB Tuesday, June 1, 2010 1:58 PM
Tuesday, June 1, 2010 1:58 PM