Search

Cannot create/shadow copy 'VariousFileName' when that file already exists. by Dwayne J. Baldwin

Resolved
as Won't Fix Help for as Won't Fix

63
0
Sign in
to vote
Type: Bug
ID: 227522
Opened: 10/16/2006 1:31:21 AM
Access Restriction: Public
13
Workaround(s)
58
User(s) can reproduce this bug
I get this message usually when in a debug/edit/debug cycle after successfully building a C# solution and pressing F5 to debug it.

Exception Details: System.IO.FileLoadException: Cannot create/shadow copy 'VariousFileName' when that file already exists.

If I wait a few moments before pressing F5 after a build, APS.NET seems to have the time to complete whatever it needs to do. This is running VS2005/ASP.NET on localhost. I can't reproduce it on purpose yet, but it happens about 10 times/hour with my current project.
Details (expand)
Product Language
English
Version
Visual Studio 2005 Team Edition for Software Developers
Operating System
Windows XP Professional
Operating System Language
English
Programming Language
C#
Technology Area
ASP.NET
Steps to Reproduce
Build/Rebuild a project. As soon as it says "Build/Rebuild Succeeded" press F5 to debug the web startup application.
Actual Results
Sometimes it works, sometimes it fails with the error message from ASP.NET.
Expected Results
It should always work, or pause until it is ready like it typically does. I did not notice this behaviour before VS2005 SP1.
File Attachments
0 attachments
Sign in to post a comment.
Posted by Dylan Baxter on 8/3/2010 at 1:15 PM
I recently started getting this error after every single project build. I tried the workarounds that didn't involve changing build tasks as I would like to avoid adding extra steps to project files that may disrupt our continuous integration build processes. Every one of these quick fixes worked great, until I rebuilt again.
This is just pitiful. Though I am used to Microsoft ignoring the pleas of its users, I was under the impression that developer feedback was considered from time to time. Add this bug to the pile of frustrations that I experience every day while developing on the Microsoft platform.
Why does Microsoft hate me?
Posted by RajfromNJ on 5/4/2010 at 12:18 PM
Error    1    The command "IF EXIST C:\PruUbixFeed\PruResendTrade\PruResendTrade\bin\PruResendTrade.dll.LOCKED (del C:\PruUbixFeed\PruResendTrade\PruResendTrade\bin\PruResendTrade.dll.LOCKED)
ELSE (IF EXIST C:\PruUbixFeed\PruResendTrade\PruResendTrade\bin\PruResendTrade.dll (move C:\PruUbixFeed\PruResendTrade\PruResendTrade\bin\PruResendTrade.dll C:\PruUbixFeed\PruResendTrade\PruResendTrade\bin\PruResendTrade.dll.LOCKED))" exited with code 9009.    PruResendTrade

2) The one by BradUffner, but I was getting another error because of that..

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

Finally, after removing all of them, thst is, bascially coming back to where I was, the project was giving me no pain. Its working fine now.

Posted by RajfromNJ on 5/4/2010 at 12:11 PM
I tried two workarounds...
1) The one suggested by cavehop, but I recieved an error because of that

Error    1    The command "IF EXIST C:\PruUbixFeed\PruResendTrade\PruResendTrade\bin\PruResendTrade.dll.LOCKED (del C:\PruUbixFeed\PruResendTrade\PruResendTrade\bin\PruResendTrade.dll.LOCKED)
ELSE (IF EXIST C:\PruUbixFeed\PruResendTrade\PruResendTrade\bin\PruResendTrade.dll (move C:\PruUbixFeed\PruResendTrade\PruResendTrade\bin\PruResendTrade.dll C:\PruUbixFeed\PruResendTrade\PruResendTrade\bin\PruResendTrade.dll.LOCKED))" exited with code 9009.    PruResendTrade

2) The one by BradUffner, but I was getting another error because of that..

Finally, after removing all of them, thst is, bascially coming back to where I was, the project was giving me no pain. Its working fine now.
Posted by Noor AJ on 3/4/2010 at 6:08 AM
Restarting IIS fixed my issue.
Posted by goggles8 on 8/18/2009 at 4:24 PM
I google this error and get over 50,000 search results and yet not fix??????
I am seriously considering moving to another platform
Posted by CarlosTheJackal on 1/21/2009 at 8:12 AM
Agreed, my whole team suffers with this problem. Seems to happen only with Enterprise Library assemblies, including Unity.
Posted by Stijn V on 9/24/2008 at 2:35 AM
It has come pretty far. Developers are now begging MS to at least acknowledge their errors. MS says hey, its fixed. If you want you can complain on this webform. Talk to the hand.
Posted by mausch on 8/19/2008 at 7:03 AM
This still happens to me with VS2008, win2k3
Posted by This_handle_has_been_reserved_by_another on 12/31/2007 at 9:26 AM
Yes, please re-open. Or at the very least, explain why you won't fix it.
Posted by roboffer on 10/10/2007 at 4:31 AM
This needs to be reopened and fixed. C'mon Bill get Visual Studio installed.
Posted by geordiepaul on 10/10/2007 at 4:22 AM
This is by far and away the most annoying Visual Studio "Bug". Everyone gets it but it would appear Microsoft won't acknowledge this and fix it!

Why won't you fix it?
Posted by mjmcmahon on 7/23/2007 at 9:22 PM
I've been experiencing this problem today as well while trying to debug and test a web service via an NUnit test class.

Environment: Visual Studio 2005 Version 8.0.50727.762
OS: Windows XP SP2
Posted by SLADR on 7/19/2007 at 3:04 AM
I also agree with nbenin, reopen it

I got this error in my release - version on "Windows 2003 Server", IIS6, .NET 2.0!

There is no visual studio installed on this machine!
Posted by Seshu Palachulla on 7/5/2007 at 2:59 PM
Ok, I just had the problem with it a few moments ago and I was surprised to this message for the first time.My Enviroment is Visual Studio 2005 on Windows Server 2003.

Ok The error came when I deleted or uninstalled an assembly from the GAC and then rebuild the new dll and tried to add it.

My work around is

1. Go to Command Prompt
2. Navigate to C:\Windows\Assembly\GAC_MSIL"
3. What is the Name of the your assembly? A folder by that assembly name exists. delete that folder
4. Try installing the Assembly once again.

It should work and you would not get the message a copy of file already exists. When you have installed successfully the folder with your assembly name that you just deleted will be recreated.

Hope it is useful

Thanks
Seshu Palachulla
Posted by lchilds on 7/3/2007 at 12:55 PM
This error happens too often and forces you to end your debug session. I agree that it needs to be resolved or at least explained.
Posted by jwrummell on 6/18/2007 at 9:17 AM
I agree with nbenin, reopen please!
Posted by Fabrice Marguerie on 5/14/2007 at 9:45 AM
Could you reopen this bug, please? It's closed as "won't fix", but without explanation. This bug is real, appeared with VS SP1 and should be fixed.
Posted by pzolja on 3/2/2007 at 9:27 AM
It usually happens when I write custom controls or use controls that I write. Restarting the web server (the one that comes with VS or IIS) or cleaning the solution fixes the problem. I wish I wouldn't have to resort to doing this though...
Sign in to post a workaround.
Posted by BradUffner on 1/19/2007 at 9:37 AM
add <hostingEnvironment shadowCopyBinAssemblies="false" /> to the <system.web> section of your web.config file.
Posted by salgo60 on 2/13/2007 at 2:51 AM
Restart Cassini when you get the problem
Posted by syrnux on 2/16/2007 at 6:30 AM
If you get the error, stop the debugger, right click the solution and "clean solution". Hit F5 to restart debugger. This is really annoying as it has >50% fail rate for me and you would think that there *should not be a manual option to CLEAN SOLUTION!* This $1200 POS application should clean it for you automatically!
Posted by cavehop on 6/11/2007 at 11:03 AM
Here's another workaround that may be more appealing to some, courtesy of Gary Farr (http://blogs.claritycon.com/blogs/gary_farr/archive/2007/03/09/2888.aspx).

Add the following to your pre-build events:
IF EXIST $(TargetPath).LOCKED (del $(TargetPath).LOCKED) ELSE (IF EXIST $(TargetPath) (move $(TargetPath) $(TargetPath).LOCKED))
Posted by 3foottall on 6/18/2007 at 9:43 AM
A workaround that does the job for me is instead of using "Build" use "Build Solution"
Posted by kbertin on 9/12/2007 at 5:58 AM
after a successful build, i count to ten, then i refresh my webform.
Posted by bgab on 9/18/2008 at 6:51 AM
I have found that by re-registering ASP.NET against IIS the problem "goes away" - I haven't had the problem since. You will need to run the following on the command line: "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis.exe -i". This more than likely won't work for everyone - it's a complex problem.
Posted by Stijn V on 9/24/2008 at 2:31 AM
I know a good workaround:

Uninstall vs2008, sell it, and download Eclipse for free.
Posted by alancnet on 12/9/2008 at 8:48 PM
Works for me:

if exist "$(TargetPath).locked" del "$(TargetPath).locked"
if exist "$(TargetPath)" if not exist "$(TargetPath).locked" move "$(TargetPath)" "$(TargetPath).locked"
Posted by zooooe on 3/5/2009 at 8:32 PM
restart VS.
Posted by clothesofsand on 9/23/2009 at 5:44 AM
When Cleaning the solution, a few warnings were issued about files that could not be deleted. These files had their read-only property set. After setting the property of these files to read/write, the problem was solved.
Posted by Noor AJ on 3/4/2010 at 6:09 AM
Restart ISS
Posted by Noor AJ on 3/4/2010 at 6:09 AM
Restart IIS