1

I've upgraded a WCF project running 3.5 vs2008 to .net 4.0 vs2010 and run into a problem. When compiling from vs2010 an assembly in my service implementation project is locked by devenv.exe (note no debugging - only compiling). The assembly is released when vs2010 is restarted and can be compiled once, after each restart. What I've tried to far:

  1. Insert PreBuild event to unlock the assembly
  2. removed assembly version wild card
  3. Disabled source stepping
  4. stopped windows search
  5. stopped IIS
  6. quit vs2010, removed sln.suo and bin/obj folder
  7. Read blog and SO posts for 3 days now :)
  8. Removed all references from the service project and readded them

I've pretty much run out of ideas and it seems that Microsoft have no explaination for this an no fix. Any ideas would be greatly appreciated!

Error Message:

Unable to copy file ".....some path...\Debug\HelperLibrary.Service.dll" to "bin\Debug\HelperLibrary.Service.dll". The process cannot access the file 'bin\Debug\HelperLibrary.Service.dll' because it is being used by another process.

Bonus information: When compiling from prompt with msbuild, there's no problem. Only when compiling from vs2010. The old vs2008 solution of course still work.

Microsoft Ticket: https://connect.microsoft.com/VisualStudio/feedback/details/682485/use-of-testaccessor-and-impl-of-codeaccesssecurityattribute-locks-assembly

Korem
  • 11,383
  • 7
  • 55
  • 72
jaspernygaard
  • 3,098
  • 5
  • 35
  • 52
  • Do you have any UserControls open in the designer? – E.Z. Hart Jul 29 '11 at 08:22
  • No UserControls in the solution. Pure WCF service. – jaspernygaard Jul 29 '11 at 09:51
  • I'm having the same issues with a WinForms project after updating to .NET Framework 4.0 in Visual Studio 2012. Hope I can get this resolved soon. – jpierson Sep 13 '12 at 08:41
  • I have the same problem every time I update a service reference. It locks the assembly containing model classes shared between client and server. I am using VS 2012 (Update 1). Never found a workaround (except restarting VS...) – Johann Blais Dec 10 '12 at 15:10

2 Answers2

0

This is a long shot, but is there any chance that your web.config has 'shadowCopyBinAssemblies' set to 'false'? Or that an upstream config file has that setting turned off?

I think that might cause the problem you're seeing.

E.Z. Hart
  • 5,717
  • 1
  • 30
  • 24
  • The web.config file is in the host project and there's no config file in the service projekt. Furthermore the text ShadowCopyBinAssemblies cannot be found in any files ... just in case it was set as an attribute. Added some bonus information to my original post. – jaspernygaard Jul 29 '11 at 10:19
0

Ok, so my colleague gets back from vacation and said he bumped into this problem earlier :) It seems that root cause for the assembly to be locked (or held by the building process), is due to the use of testaccessors to test private methods, in combination of an implementation of CodeAccessSecurityAttribute. Note that this is not a problem in Visual studio 2008, but only in 2010 See another case here:

http://social.microsoft.com/Forums/en/Offtopic/thread/41ceebce-1ecf-4962-86d0-e68050df4a99

I've yet to find a solution for this, besides altering the private methods to public - I'll create a new post for this problem.

jaspernygaard
  • 3,098
  • 5
  • 35
  • 52