LP on .NET

July 7, 2009

Visual Studio 2008 Unit Testing Bug

Filed under: .NET,C#,Visual Studio,VSTS — Larry Parker @ 11:47 am

I just ran into a bit of a nasty bug in Visual Studio 2008 while doing some unit testing.  At some point after a bunch of edit / compile / unit test iterations, I got the following error trying to compile my solution:

API restriction: The assembly ‘file:///C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\PublicAssemblies\Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll’ has already loaded from a different location. It cannot be loaded from a new location within the same appdomain

Restarting Visual Studio did not help.  Neither did cleaning and rebuilding my solution.

I found this thread on the MSDN VSTS forum which discusses the problem.  Microsoft apparently could not reproduce the problem, and closed out a bug report submitted to Microsoft Connect as “Closed (Not Reproducible)”.

If you’re running into this problem, I recommend reading through the entire forum thread, because the solution does not seem to be so cut and dry.

But for me, deleting my solution’s user options file (e.g. MySolution.suo) did the trick.

Hope this helps.



  1. […] I couldn’t remember what the fix was.  Fortunately I blogged about it and found the answer here (the fix once again was to delete my solution’s user options […]

    Pingback by Let’s Hear it for Blogging « LP on .NET — August 1, 2009 @ 11:06 am | Reply

  2. The problem occurs when you have multiple projects in the same solution that contain references to the same library. In your case, ‘Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll’.

    A solution is perhaps to have a single UnitTest project, or have different solution configurations that build the unit test projects separately.

    Comment by Elizeu Santos-Neto — August 20, 2009 @ 1:47 pm | Reply

  3. Thanks for the tip. Our solution is pretty large, so a single unit test project might not be feasible. But if I keep running into this problem, we may have no choice.

    Thanks again.

    Comment by Larry Parker — August 20, 2009 @ 9:05 pm | Reply

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at WordPress.com.

%d bloggers like this: