none
error MSB3021 Un able to copy ..... RRS feed

  • Question

  • hi

    when i try to build my solution in vs2005 . i get this error from time to time

    Compile complete -- 0 errors, 0 warnings

    C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Microsoft.Common.targets(2313,9): error MSB3021: Unable to copy file "obj\Debug\Config.dll" to "bin\Debug\Config.dll". The process cannot access the file 'bin\Debug\Config.dll' because it is being used by another process.

    Done building project "Config.csproj" -- FAILED.

     

    as chack this file i can see the only process using it is Vs2005


    D:\download\Handle>handle config.dll

    Handle v3.11
    Copyright (C) 1997-2005 Mark Russinovich
    Sysinternals - www.sysinternals.com

    devenv.exe         pid: 1612    7F8: C:\Documents and Settings\AmitK\Local Settings\Application Data\Microsoft\VisualStudio\8.0\ProjectAssemblies\bgplnu7n01\Config.dll
    devenv.exe         pid: 1612    948: C:\Documents and Settings\AmitK\Local Settings\Application Data\Microsoft\VisualStudio\8.0\ProjectAssemblies\ert0qo0t01\Config.dll
    devenv.exe         pid: 1612    AD8: D:\dev\Config\bin\Debug\Config.dll

    D:\download\Handle>

     

    so how can i work around this problam ?

     

    amit kuzi

    Thursday, June 29, 2006 8:28 AM

Answers

  • Jakob,

    If you're still having this problem the best thing at this point is to file a bug using the directions at the top of the forum. We'll most likely need a minimal repro case that works on any machine that you can zip up and share.

    Thanks in advance

    Dan

    Wednesday, August 9, 2006 5:59 PM
    Moderator

All replies

  • Can you please try adding this property under the first PropertyGroup in your project file?

    <GenerateResourceNeverLockTypeAssemblies>true</GenerateResourceNeverLockTypeAssemblies>

    Let us know if that works.

    Dan

    Saturday, July 8, 2006 7:15 PM
    Moderator
  • I have the same problem as described in this thread.

    The problem occurs in only two of the projects in our solution of 23 projects. I have tried to use <GenerateResourceNeverLockTypeAssemblies>true</GenerateResourceNeverLockTypeAssemblies>

    Property in the projects with problem, but with no result.

     

    I have read in various threads that the problem also could occur if the copy local property vas set to false. But it is not set to false in any for any of the projects in the solution.

     

    Any other suggestions to the problem??

     

    BR Jakob Højgaard

     

    Oticon A/S

    Monday, July 10, 2006 12:59 PM
  • Jakob,

    If you're still having this problem the best thing at this point is to file a bug using the directions at the top of the forum. We'll most likely need a minimal repro case that works on any machine that you can zip up and share.

    Thanks in advance

    Dan

    Wednesday, August 9, 2006 5:59 PM
    Moderator
  • I ran into this problem today compiling a multi-project VS2005 solution and it actually was directly specific to a "project reference" copy local property being set to false.  My solution contained a mix of BizTalk 2006 and C# Class Library projects.  

    If you have any "project references", I would try removing them and re-adding them.  The copy local property will be initially set to true as the IDE computes the most appropriate value for this property when the reference is made. 

    Not sure if this will help, but worth a try...definitely curious to see what the fix will be for this one.

    Regards,

    MH

     

     

    Saturday, August 12, 2006 12:59 AM
  • ...similar problem with msbuild and MSB3021 error message:

    problem was that in one project .csproj file were redundant links to the assemblies from \bin\ (same as References)
    Thursday, September 27, 2007 11:49 PM
  • I had the same problem that has been reported here and in many other forums,

     

    I put the <GenerateResourceNeverLockTypeAssemblies>true</GenerateResourceNeverLockTypeAssemblies> property into the solutions Startup Project's csproj file as the first Property in the first PropertyGroup and since then I haven't had the problem. (fingers crossed)

     

    Brett

    Thursday, November 8, 2007 10:20 PM
  • I encountered this productivity killing issue and after doing all of the usual:

    > Removing references and recreating

    > Turning of indexing

    > Pre / post compile scripts

    > <GenerateResourceNeverLockTypeAssemblies>true</GenerateResourceNeverLockTypeAssemblies>

    Found the solution to be:

    Changing the assembly name from Security to PSS.Security in the project properties.

    It clicked that the error had occured when I changed my assemblies to not have the name space in front of them the night before eg. WAS [Company].PSS.Security.dll CHANGED TO JUST Security.dll.

    I changed it back and the x.x.vshost.exe MSB3021 lock was not appearing any more on run. As a further test I changed it back to just Security.dll and it failed again... changed it to Something.Security.dll and it worked again.

    Hope this helps find a permanent fix (which really is needed) and a workaround in the meantime.

    • Edited by overbaud Tuesday, April 24, 2012 4:09 AM Removed personal details
    Thursday, February 28, 2008 5:08 AM
  • This was a really helpful post - I had a DLL library with some composite webcontrols and I had called it WebControls. Internally, I had put my own namespace in, but the dll was being called webcontrols.dll. As soon as I renamed it to IO.WebControls.dll the compilation issue went away. Not sure why it worked some of the time and not others, but this stopped it (have built 5/6 times without the error now, and it was occuring every time before!)
    • Proposed as answer by TFSNord Wednesday, May 20, 2009 10:57 PM
    Monday, February 9, 2009 11:55 AM
  • The following workaround worked for one build but the next one failed again. Does anybody know the permanent fix?

    ERROR 1.

    C:\WINDOWS\Microsoft.NET\Framework\v3.5\Microsoft.Common.targets(2703,9): error MSB3021: Unable to copy file "xxxxx.pdb" to "xx\xx\xx.pdb". The process cannot access the file 'xxxxx.pdb' because it is being used by another process.

    RESOLUTION

    ADD the folowing property in all the .csproj where you are getting “because it is being used by another process” error. In my case it was Nordstrom.Web.External and Nordstrom.Web.External.UnitTest

     

    <GenerateResourceNeverLockTypeAssemblies>true</GenerateResourceNeverLockTypeAssemblies>

     

    ERROR 2.

    C:\WINDOWS\Microsoft.NET\Framework\v3.5\Microsoft.Common.targets(2703,9): error MSB3021: Unable to copy file "yyyyy.dll" to "yy\yy\yy.dll". Access to the path 'yy\yy\yy.dll' is denied.

     

    RESOLUTION

    ADD the folowing property in TFSBuild.Proj

    <CustomPropertiesForBuild>OverwriteReadOnlyFiles=true</CustomPropertiesForBuild>

    Thursday, May 21, 2009 4:31 PM
  • The error is because your project reference or one of its dependency's project refrence(s) has been added to your project .

    Just remove these refrences , the problem will solve.

     

    • Edited by NAVIDz Tuesday, April 6, 2010 5:44 AM mistake
    Tuesday, April 6, 2010 5:40 AM
  • I finally found the solution thx to this post.

    I examined the References used by my startup project, and the project had a Reference to itself!! Therefore VS2010 was trying to copy the exe generated by the project in the /obj folder, to the /bin/Debug folder while is was building the project, and thereby failing.

    I removed the reference, and all works fine again.

    Im somehow suprised though, why VS2010 couldnt determine that there was a circular reference? A project, with a reference to itself?

     

    Monday, May 31, 2010 12:07 PM
  • I finally found the solution thx to this post.

    I examined the References used by my startup project, and the project had a Reference to itself!! Therefore VS2010 was trying to copy the exe generated by the project in the /obj folder, to the /bin/Debug folder while is was building the project, and thereby failing.

    I removed the reference, and all works fine again.

    Im somehow suprised though, why VS2010 couldnt determine that there was a circular reference? A project, with a reference to itself?

     

    hi Anders Fredborg ,


    please can you explain more because i still have this problem :(

    this is my project that i have problem in it

    http://www.4shared.com/file/zGd1_v7A/XO_Game.html

    if you or any one can help me, i will be pleased to him/her.

    and this is the error that i have :

    Error 1 Unable to copy file "obj\Release\XO_Game.exe" to "bin\Release\XO_Game.exe". The process cannot access the file 'bin\Release\XO_Game.exe' because it is being used by another process. XO_Game

    thanks in advance

    • Proposed as answer by James Horms Monday, July 12, 2010 4:11 PM
    Saturday, July 10, 2010 4:57 AM
  • Esraa,

    The link you have provided doesnt work.

     

    But you need to examine all the references that each of your project has using the solution explorer, and check that the project doesnt have a reference to itself.

    In your case, examine References of your Game project, and check that there isnt a Reference to "Game.dll" - if it is there, remove it.

     

    Hope it helps

     

    Wednesday, July 28, 2010 8:59 AM
  • Can you please try adding this property under the first PropertyGroup in your project file?

    <GENERATERESOURCENEVERLOCKTYPEASSEMBLIES>true</GENERATERESOURCENEVERLOCKTYPEASSEMBLIES>

    Let us know if that works.

    Dan


     It failed to solve my problem, Could you give more details? 
    Saturday, October 23, 2010 12:18 AM
  • I just fought with this error for a few hours. For me, it was only happending during Release builds.

    The problem was that I had accidentally added bin\Release\MyAppName.exe to source control so it was being downloaded to our build server as ReadOnly and then causing this error.

    After removing it from source control and deleting the contents of the workspace on the build machine, my project builds OK.

    Saturday, December 4, 2010 1:33 AM
  • I wanted to share this since I went through this pain as well. My issue was that the bin directory and a dll under that was checked into TFS accidently. I removed the contents of the bin directory from TFS and that fixed the build.
    Monday, March 7, 2011 4:15 PM
  • Can you please try adding this property under the first PropertyGroup in your project file?

    <GenerateResourceNeverLockTypeAssemblies>true</GenerateResourceNeverLockTypeAssemblies>

    Let us know if that works.

    Dan

    Hi,

    I don't understand where I need to put this. In what file?

    Thank you.

    Olivier.

    Sunday, October 30, 2011 9:36 PM
  • it's because VS2010 is dodgy product.

    Dipak Bava

    Wednesday, March 14, 2012 2:51 PM
  • hai remarkpk11,

    i am encountering the following problem when i debug my project. 

    Error 1 Unable to copy file "obj\Debug\Userlivestreamerprocss.exe" to "bin\Debug\Userlivestreamerprocss.exe". The process cannot access the file 'bin\Debug\Userlivestreamerprocss.exe' because it is being used by another process. Userlivestreamerprocss

    Now tell me what to do in simple understandable steps 
    Tuesday, March 27, 2012 12:33 PM
  • open task manager ---> got to processes tap and then search for all Userlivestreamerprocss.exe click on it an then press end task

    Then try to run your application again :)

    Good luck ^_^

    • Proposed as answer by gogosweb Monday, November 2, 2015 2:59 PM
    • Unproposed as answer by gogosweb Monday, November 2, 2015 2:59 PM
    Tuesday, March 27, 2012 1:43 PM