Debugging assembly load issue

5

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.

c#
.net
visual-studio
mstest
fileloadexception
asked on Stack Overflow Apr 7, 2009 by toxvaerd • edited Apr 7, 2009 by toxvaerd

3 Answers

2

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.

answered on Stack Overflow Jun 4, 2009 by Scott Lawrence
1

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.

answered on Stack Overflow Apr 7, 2009 by Mark Dickinson
0

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.

answered on Stack Overflow May 11, 2009 by toxvaerd

User contributions licensed under CC BY-SA 3.0