I am currently working on a project that is using MS Test for unit testing. When I do a "Run All Tests" I get the following error for about 1/3 of the tests:
Test method [Test Method] threw exception System.IO.FileLoadException, but exception System.InvalidOperationException was expected. Exception message: System.IO.FileLoadException: Loading this assembly would produce a different grant set from other instances. (Exception from HRESULT: 0x80131401)
If I go to any of the failing tests and Run the test by itself it will give the same error. If I put a break point in the test and debug the test it will pass with no errors. If I again run the individual test it will pass. If I go back to running all tests I get the above error for 1/3 of the tests again.
I had this problem before and I didn't do anything to fix it and it just magically went away. But now it is back and very frustrating.
What is causing this error? Is there a fix for this error?