Jakob Ehn

Visual Studio ALM MVP @Inmeta Crayon
posts - 45, comments - 240, trackbacks - 0

My Links

News

Microsoft Community Contributor Award 2011

Twitter





Tag Cloud

Archives

Post Categories

Blogs

TFS 2010 Build: Dealing with the API restriction error

Recently I’ve come across this error a couple of times when running builds that exeucte unit tests using Test containers:

API restriction: The assembly 'file:///C:\Builds\<path>\myassembly.dll' has already loaded from a different location. It cannot be loaded from a new location within the same appdomain.

Every time I’ve got this error, the project has been a web application, and the path to the assembly points down to the _PublishedWebsites directory that is created beneath the Binaries folder during a team build.

The error description really says it all (although slightly cryptic), when using test containers, MSTest needs to load all assemblies and see if they contain any unit tests. During this serach, it finds the ‘myassembly.dll’ in two different locations. First it is found directly beneth the Binaries folder, and then it is alos found beneath the _PublishedWebsites\Project\bin folder. The reason is that the default setting for test containers in a TFS 2010 build definition is **\*test*.dll:

image

 

This pattern means that MSTest will search recursively for all assemblies beneath the Binaries folder, and during the search it will find the MyAssembly.dll twice.
The solution is simple, set the Test assembly file specification property to *test*.dll instead, this will disable the recursive search:

image

Print | posted on Tuesday, June 08, 2010 6:08 AM | Filed Under [ TFS Team Build VSTS 2010 ]

Feedback

Gravatar

# re: TFS 2010 Build: Dealing with the API restriction error

It worked for me. tnks!
6/8/2010 10:41 PM | afsharm
Gravatar

# re: TFS 2010 Build: Dealing with the API restriction error

Thanks Jakob. Your solution solved my problem too. I had a web project named "WebTest" that contained no unit test.
8/17/2010 11:06 PM | Afshar Mohebbi
Gravatar

# re: TFS 2010 Build: Dealing with the API restriction error

Thanks for the solution. it worked...:)
8/31/2010 9:57 AM | Suneel
Gravatar

# re: TFS 2010 Build: Dealing with the API restriction error

Thanks. It solved my problem too.
10/27/2010 6:18 AM | Vijay
Gravatar

# re: TFS 2010 Build: Dealing with the API restriction error

Jakob's post helped me look at the right places for the problem. But there is more to this problem then just the above fix. Visit my blog at
http://archpulse.wordpress.com/2010/11/24/tfs-2010-customize-build-output-changes-and-ms-tests/

Look at the tailend for possible other causes of this issue.
11/26/2010 3:19 AM | archpulse
Gravatar

# re: TFS 2010 Build: Dealing with the API restriction error

Great solution!, Thank you.
3/18/2011 11:58 AM | Wamiq Ansari
Gravatar

# re: TFS 2010 Build: Dealing with the API restriction error

it took me ages to figure out how to apply this setting, I couldn't find the dialog in the screenshot above. I eventually changed it by doing the following:

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: Modify value or delete altogether if needs be
5/4/2011 11:17 AM | Jonathan Mc Namee
Gravatar

# re: TFS 2010 Build: Dealing with the API restriction error

Thanks for the post, helped quickly to resolve the issue.
8/26/2011 7:08 PM | Vijay
Gravatar

# re: TFS 2010 Build: Dealing with the API restriction error

Thanks Jakob, in my case we included a dll called JSTest.dll for unit-testing javascripts...
9/29/2011 9:36 AM | DAvid sundström
Gravatar

# re: TFS 2010 Build: Dealing with the API restriction error

Thank you so much its great.
1/3/2012 11:32 AM | Shashank
Gravatar

# re: TFS 2010 Build: Dealing with the API restriction error

Excellent explanation and great solution, Thanks.

To Jonathan Mc Namee:
The place to apply this setting is actually in your project build definition, right click "your build definition", "Edit build definition...", click "Process", the setting is in "2 Basic" - > Automated Tests
3/20/2012 6:00 PM | WayneRazor
Gravatar

# re: TFS 2010 Build: Dealing with the API restriction error

Great, thanks a lot!
4/19/2012 9:41 AM | Marco
Gravatar

# re: TFS 2010 Build: Dealing with the API restriction error

This worked for me. Thank you.
5/1/2012 3:32 PM | Pawan
Post A Comment
Title:
Name:
Email:
Website:
Comment:
Verification:
 
 

Powered by: