views:

1152

answers:

3

Hi, I have a very wierd problem happening to me during unit testing (MSTest in Visual Studio - .NET 3.5 SP1):

  1. I click "Run All Tests in solution"
  2. All tests passes, except for one particular class, where every tests throws the following exception: "System.IO.FileLoadException: Loading this assembly would produce a different grant set from other instances. (Exception from HRESULT: 0x80131401)."
  3. I then go and set a breakpoint in the class. Result: all tests in the class passes (the same tests that failed before).
  4. I click "Run All Tests in solution". All tests passes, except for another class.
  5. I go set a breakpoint in the class. Result: All tests in the class passes
  6. I click "Run All Tests in solution". All tests passes, except for the first testclass again.
  7. etc.

As you can see the problem is very inconsistent, making it hard to debug.

I've tried using Fusion Log Viewer, but that gave me confusing results I didn't quite understand.

What should I be looking for? Has anyone else experienced this problem?

Update: Some additional info was requested.

The tests has run fine for months - I think last time I ran them was thursday, and then they ran fine. I've been trying to examine the source control history, to see if something has changed, but nothing out of the ordinary.

I could track back and check out the project at different days back in time, but we're using Visual Source Safe (I know - not my descission :-( ) so I'm hesitating to do that.

The tests are regular unit tests, and I'm using Moq for mock-objects... But as I said - it has worked fine until recently.

I was just hoping for some advice on how to debug this issue.

+1  A: 

Apparently it is a bug. No doubt you've already found this but just in case, here's a link.

http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=95157

Hope it helps.

Mark Dickinson
I've found that page and have tried implementing some of the workarounds, and they do not help. Besides, the bug is described as a 2.0 issue - I'm using 3.5 SP1, so the bug should be fixed?
toxvaerd
Could you tell us more about the test and the code being tested. All the info I can find points to the bug, or restarting the server, deleting temp files etc. The test may run under a different context or user, with less permissions, sorry if this is obvious.
Mark Dickinson
A: 

The problem described here is only occuring on my machine. I tried purging my VS2008 settings, disabling all Add-Ins and checking the project out on a different location, but neither worked. Right now I think the last possible solution before a reformat of the machine is reinstalling VS2008, which I don't have time for at the moment, so I will just have to live with the issue for now.

toxvaerd
+1  A: 

We encountered this issue as well, though it only happened on our build server (where we have VS2008 installed in order to use MSTest with MSBuild), not locally. We installed this hotfix in the version of VS2008 on the build server and that eliminated this problem.

Scott A. Lawrence