13

The following error pops up every now and then:

C:\Program Files\MSBuild\Microsoft\VisualStudio\v9.0\TeamTest\Microsoft.TeamTest.targets(14,5): error : 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.

How do I get rid of it?

abatishchev
  • 98,240
  • 88
  • 296
  • 433
Kevin Driedger
  • 51,492
  • 15
  • 48
  • 55

2 Answers2

8
  • Edit the .csproj file
  • Remove the processorArchitecture=MSIL on the end of the UnitTestFramework reference.

Change:

<reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />

to:

<reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
  • Restart Visual Studio
Natrium
  • 30,772
  • 17
  • 59
  • 73
Kevin Driedger
  • 51,492
  • 15
  • 48
  • 55
  • 1
  • This worked for me the first time, but since then, I'm getting the same problem with the same test project. I've checked the .csproj file and the ProcessorArchitecture bit definitely isn't there, I thought it might have been put back somehow, but it hasn't. – TabbyCool Jul 13 '11 at 09:41
  • 2
    Kevin: Can you explain the thinking behind this? I'm running into the same problem, but have seen conflicting explanations of what's going on. – Stephen Gross Nov 16 '11 at 22:48
  • This worked for me, while having the same error. Still, sometimes it didn't worked until I cleaned and rebuilt the project. – Coral Doe Apr 15 '13 at 13:20
5

If you are getting this error when it tries to run the tests on your TFS Build Server, then you may just have to change the pattern that the TFS build definition uses to locate test assemblies. This post describes the problem and solution. Basically TFS is finding the same test assembly in two different folders and tries to include it twice. To fix this:

  1. Open Team Explorer
  2. Expand tree until you see builds for your project
  3. Select the build in question
  4. Right Click > Edit Build Definition
  5. Click Process on side bar on left
  6. Expand '2. Basic' > Automated tests
  7. Click Edit
  8. Change the Test assembly file specification to remove matching a folder in the pattern. E.g. change ****\test.dll** to *test*.dll

By removing the folder from the match pattern (i.e. the \) it will only include the test assembly once, even if it finds it in two different folders.

deadlydog
  • 22,611
  • 14
  • 112
  • 118