Unit tests fail to queue RRS feed

  • Question

  • User1097717471 posted

    *** UPDATE: worked around issue by shutting down Visual Studio, opening a command prompt, then issuing the command: caspol -reset ***

    Sorry if this post is not in the correct section, did not see a section that looked like a dead ringer for where this post should be placed.

    We have recently implemented a rather extensive library of unit test for our systems.  As we were authoring the unit tests we had our assemblies building using the Debug configuration.  The unit tests ran fine.  During the development cycle we changed the configuration to Release, re-built and again the tests ran fine.  This is where things got wierd.  When we reverted the build configuration back to Debug, all of the tests now fail to queue.  The error reported is: "Failed to queue test run 'user@machine 2009-09-11 08:55:12': Invalid syntax.".  The calls stack indicates some sort of Code Access Security issue:

       System.Security.XmlSyntaxException: Invalid syntax.
       at System.Security.SecurityDocument.GetTagForElement(Int32 position)
       at System.Security.Policy.PolicyStatement.FromXml(SecurityDocument doc, Int32 position, PolicyLevel level, Boolean allowInternalOnly)
       at System.Security.Policy.PolicyLevel.CheckCache(Int32 count, Char[] serializedEvidence)
       at System.Security.Policy.PolicyLevel.Resolve(Evidence evidence, Int32 count, Char[] serializedEvidence)
       at System.Security.PolicyManager.CodeGroupResolve(Evidence evidence, Boolean systemPolicy)
       at System.Security.PolicyManager.ResolveHelper(Evidence evidence)
       at System.Security.HostSecurityManager.ResolvePolicy(Evidence evidence)
       at System.Security.PolicyManager.Resolve(Evidence evidence)
       at System.Security.SecurityManager.ResolvePolicy(Evidence evidence)
       at Microsoft.VisualStudio.TestTools.Common.FileHelper.IsTrustedForLocalExecution(String path)
       at Microsoft.VisualStudio.TestTools.TestManagement.DeploymentHelper.IsTrustedForLocalExecution(String path, TestRunConfiguration runConfig, String& untrustedFile)
       at Microsoft.VisualStudio.TestTools.TestManagement.DeploymentHelper.IsDeploymentFromUntrustedLocation(TestRunConfiguration runConfig, List`1 tests, List`1 dependencies, DeploymentItemCollection perTestDeploymentItems, String& firstUntrustedFile)
       at Microsoft.VisualStudio.TestTools.TestManagement.DeploymentManager.DoDeployment(TestRun run, FileCopyService fileCopyService)
       at Microsoft.VisualStudio.TestTools.TestManagement.ControllerProxy.SetupTestRun(TestRun run, Boolean isNewTestRun, FileCopyService& fileCopyService)
       at Microsoft.VisualStudio.TestTools.TestManagement.ControllerProxy.QueueTestRunWorker(Object state)

    We cannot get these tests to run on this buildI have found some Microsoft KB articles talking about unit tests and test failures.  The steps detailed in these articles do not resolve this issue.  I think this may only happen when working with strongly named assemblies, we have not validated this statement at this time though.

    Anyone have any insight as to what might be going on here?  We have already created a new test project (With a different name), reset the CAS settings using CASPOL, creating a new .vsmdi file, creating a new localtestrun.config file, cleaning the solution, and deleting all bin and obj folders then rebuilding to no avail.  Any advice is greatly appreciated.

    Tuesday, September 15, 2009 3:20 PM


All replies

  • User372121194 posted


    Thanks for sharing the solution. This is the Code Access Security Policy issue. You can run caspol with -reset option to reset policy to its default state.

    For more information, see http://msdn.microsoft.com/en-us/library/cb6t8dtz(VS.80).aspx



    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, September 21, 2009 2:42 AM
  • User-903699315 posted

    I had to add the -all option to caspol for it to work:

    caspol -all -reset

    Friday, April 19, 2013 5:03 PM