Adsense

Thursday, September 06, 2007

WPF - Error 3 API restriction: The assembly 'file:///C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\PublicAssemblies\Microsoft.VisualStu

I was getting any annoying error (see below) in Visual Studio 2008 (Team System) Beta II after doing an SVN update. Every time I would try to compile our solution, I would get an error in our UnitTest project. The error was complaining that the UnitTestFramework.dll was being loaded from two different locations within the same appdomain.

"Error 3 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."

The problem was that two of the projects in our solution were referencing UnitTesting DLLs. For some reason someone added references to the following two libraries in our DAL project, and the compiler was throwing a fit that the UnitTestFramework dll was getting loaded from two different locations within the appdomain.

  • Microsoft.VisualStudio.QualityTools.UnitTestFramework
  • Microsoft.VisualStudio.TeamSystem.Data.UnitTesting

Removing these two (unneeded) references from our DAL project fixed the issue, but the error seemed a bit vague.

(NOTE: You may need to close and then reopen Visual Studio since the library might still be loaded...) =( Took me 10 minutes to figure this out...)

5 comments:

Unknown said...

Thank you for your help - you saved me valuable time.

Anonymous said...

Thanx very much! It saved a lot of time for out team

Unknown said...

nice work. This was a very annoying problem. I found that I had to re-add the references after I deleted them and restarted Visual Studio.

Kirk Davis said...

Hey, thanks for posting this - especially the "might have to restart Visual Studio" bit.

I spent roughly an hour trying to figure out why my DAL (which uses LINQ, and references system.data.linq) and the WPF application, which also needs to reference that, was refusing to let me build.

What an annoying bug, I really hope Microsoft fixes this with the next SP of VS2008. Thanks again!

Kirk

Anonymous said...

see this other solution at http://stackoverflow.com/questions/1725210/how-do-i-get-rid-of-api-restriction-unittestframework-dll-already-loaded-error/4091633#4091633