ASP.Net cannot create/shadow copy
Solution 1
The following workarounds come from this now defunct connect issue:
- add
<hostingEnvironment shadowCopyBinAssemblies="false" />
to the<system.web>
section of your web.config file. - Restart Cassini when you get the problem
- 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!
- 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))
A workaround that does the job for me is instead of using "Build" use "Build Solution"
- After a successful build, I count to ten, then I refresh my webform.
- 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. - restart VS.
- 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.
- Restart IIS
EDIT: Items retrieved from an old version of the page (courtesy of archive.org).
Solution 2
Wait somewhere between 10-30 seconds and hit refresh. For some reason this always works for me.
Solution 3
Just restart Visual studio, that worked for me.
Solution 4
Open your project properties, open the Web tab and make sure the Enable Edit and Continue option is not checked.
Solution 5
In my situation only iisreset
worked.
david.mchonechase
Updated on May 18, 2021Comments
-
david.mchonechase almost 3 years
I get this error repeatedly when developing ASP.Net applications:
Cannot create/shadow copy 'XXXXX' when that file already exists
Where XXXXX is a random DLL. Typically the DLL is one of the DLLs from Microsoft's Enterprise Library, but it varies.
It's really random, and it's very frustrating. I will go hours without getting the error, and then get this error every 10-20 minutes.
I've seen several solutions. For instance, this question. I've tried using Clean Solution option, and I've also simply restarted my local IIS. However, it still occurs at the same random but persistent frequency.
I've also seen many people mention using this option in the config file:
<hostingEnvironment shadowCopyBinAssemblies="false" />
However, others have mentioned it being problematic, and it should definitely not be used in production.
So, should I just give up and try the shadowCopyBinAssemblies option? (And make sure not to copy this change to other environments.) Am I the only one who gets this issue that often?
Note: I am using Visual Studio 2008.
-
Eric Lennartsson almost 14 yearsI'm repeatedly getting this error and I'm surprised Microsoft still have not fixed this.
-
RickAndMSFT over 11 yearswe're actively working on this now. Given it's really hard to reproduce, it makes fixing the problem more difficult.
-
Luke Puplett about 11 yearsI've resubmitted the connect bug, just so it can be tracked by MS customers. connect.microsoft.com/VisualStudio/feedback/details/786247/…
-
BornToCode over 10 years@RickAndMSFT - "really hard to reproduce"? it happens all the time (especially when using IIS Express), look at the views number of this post.
-
-
CRice almost 15 yearsok, nothing to do with version then. If you do a rebuild solution does your application run?
-
david.mchonechase almost 15 yearsYes, I "clean" the solution, rebuild, and work for 10-20 minutes. Then I get the error again and repeat.
-
AlejandroR almost 15 yearsI got the same issue while working with DotNetNuke. It disappeared magically after fixing a wrong PortalAlias. Strange things happens. As an alternative to the hostingenviroment setting: Add this to the Pre-Build event command line: IF EXIST $(TargetPath).LOCKED (del $(TargetPath).LOCKED) ELSE (IF EXIST $(TargetPath) (move $(TargetPath) $(TargetPath).LOCKED))
-
Kirk Woll about 13 yearsThanks for the link, but took some sifting. The one that worked for me was "after a successful build, i count to ten, then i refresh my webform." (though I only counted to 2)
-
m-smith almost 12 yearsBest fix from that link for me was "restart IIS". I'm running local IIS instead of Cassini as my dev web server. Cheers. P.S. I'm using VS2010, so they still haven't fixed it.
-
RickAndMSFT over 11 yearsWhich works exactly the same as go smoke a cigarette and the issue will go away
-
Zafar over 10 yearsit worked because the main reason for this issue is trying to access the webpage before the build process is finished in VS.
-
joshcomley about 10 yearsThat's interesting, Zafar. Do you have any more information on that? This bug drives me crazy sometimes!
-
Zafar about 10 yearsThe only thing I know about this is - you get this error when you try to access a webpage before the dependent DLL files are finished to build. Well, that is not the only case for the error I think, but this one is most popular.