Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get rid of "API restriction UnitTestFramework.dll already loaded" error?

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?

like image 429
Kevin Driedger Avatar asked Nov 12 '09 20:11

Kevin Driedger


2 Answers

  • 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
like image 72
Kevin Driedger Avatar answered Oct 06 '22 01:10

Kevin Driedger


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.

like image 30
deadlydog Avatar answered Oct 06 '22 00:10

deadlydog