Cannot create/shadow copy 'File Name' when that file already exists

Posted by Anuraj on Thursday, September 12, 2013 Reading time :1 minute

.Net .Net 4.0 ASP.Net ASP.Net MVC Visual Studio

Sometimes while debugging ASP.Net applications, intermittently you may get an error like this.

Cannot create/shadow copy

The .Net Framework has a feature called Shadow Copy. Shadow copy is enabled on every appdomain created by ASP.NET by default. By default assemblies loaded will be copied to a shadow copy cache directory, and will be used from that location. ASP.Net does this because the original file is not locked and can be modified. This error can be resolved, if you wait a few moments before pressing F5 after a build, ASP.NET seems to have the time to complete whatever it needs to do.

You can also modify web.config to resolve the issue.

   <hostingEnvironment shadowCopyBinAssemblies="false" />

Happy Programming.

What do you think? I would like to hear your thoughts, suggestions, and questions in the comments section below.

Did you like this article? Share it with your friends

Facebook Twitter Google+ LinkedIn Reddit StumbleUpon

BMC logoBuy me a coffee

Copyright © 2019 - Anuraj P. Blog content licensed under the Creative Commons CC BY 2.5 | Unless otherwise stated or granted, code samples licensed under the MIT license. This is a personal blog. The opinions expressed here represent my own and not those of my employer. Hosted with ❤ by GitHub