blog

TFS Error: MSB4018 The “BuildShadowTask” task failed unexpectedly

Published on
2 minute read

There seams to be a problem in MSBuild when you add an “Accessor” as part of a Unit Test project.

C:Program FilesMSBuildMicrosoftVisualStudiov9.0TeamTestMicrosoft.TeamTest.targets(14,5): error MSB4018: The "BuildShadowTask" task failed unexpectedly.
System.IO.FileLoadException: API restriction: The assembly 'file:///C:WINDOWSMicrosoft.NETFrameworkv2.0.50727System.Web.dll' has already loaded from a different location. It cannot be loaded from a new location within the same appdomain.
   at System.Reflection.Assembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection)
   at System.Reflection.Assembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection)
   at System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
   at System.Reflection.Assembly.InternalLoadFrom(String assemblyFile, Evidence securityEvidence, Byte[] hashValue, AssemblyHashAlgorithm hashAlgorithm, Boolean forIntrospection, StackCrawlMark& stackMark)
   at System.Reflection.Assembly.ReflectionOnlyLoadFrom(String assemblyFile)
   at Microsoft.VisualStudio.TestTools.UnitTesting.Publicize.WebBinder.LoadData()
   at Microsoft.VisualStudio.TestTools.UnitTesting.Publicize.WebBinder.Init()
   at Microsoft.VisualStudio.TestTools.UnitTesting.Publicize.Shadower..ctor()
   at Microsoft.VisualStudio.TestTools.BuildShadowReferences.BuildShadowTask.Execute()
   at Microsoft.Build.BuildEngine.TaskEngine.ExecuteInstantiatedTask(EngineProxy engineProxy, ItemBucket bucket, TaskExecutionMode howToExecuteTask, ITask task, Boolean& taskResult)

An Accessor allows your test project to access code that would normally be “Private” or “Friend” from outside the Assembly that it resides in.

TFS Error: MSB4018 The "BuildShadowTask" task failed unexpectedly  

It creates a little file with the “.accessor” extension that is the same name as your DLL, and contains the name of the DLL.

TFS Error: MSB4018 The "BuildShadowTask" task failed unexpectedly  

If you remove this file then your remote MSBuild server will then build you solution successfully again including running your Unit Tests.

Reference:

Re: BuildShadowTask Failed unexpectedly - Accessor Problem (Upconvert VS 2005 to 2008) – URGENT 

BuildShadowTask Failed unexpectedly - Accessor Problem (Upconvert VS 2005 to 2008) – URGENT 

Technorati Tags: ALM    TFBS    TFS 2008    VS 2005 

blog tfs-build tfs tfs2008 tools visual-studio vs2005

Related blog posts

No related videos found.

Connect with Martin Hinshelwood

If you've made it this far, it's worth connecting with our principal consultant and coach, Martin Hinshelwood, for a 30-minute 'ask me anything' call.

Our Happy Clients​

We partner with businesses across diverse industries, including finance, insurance, healthcare, pharmaceuticals, technology, engineering, transportation, hospitality, entertainment, legal, government, and military sectors.​

Boeing Logo
Trayport Logo
Ericson Logo
Akaditi Logo
Epic Games Logo
Cognizant Microsoft Business Group (MBG) Logo
Illumina Logo
Hubtel Ghana Logo
Graham & Brown Logo
MacDonald Humfrey (Automation) Ltd. Logo
Flowmaster (a Mentor Graphics Company) Logo

CR2

Philips Logo
Sage Logo
ProgramUtvikling Logo
SuperControl Logo
Kongsberg Maritime Logo
Milliman Logo
Royal Air Force Logo
Nottingham County Council Logo
Washington Department of Transport Logo
Department of Work and Pensions (UK) Logo
Washington Department of Enterprise Services Logo
Ghana Police Service Logo

CR2

Slaughter and May Logo
Slicedbread Logo
Microsoft Logo
Schlumberger Logo
Lockheed Martin Logo