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

September 12, 2013 by Anuraj

.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.

Copyright © 2024 Anuraj. 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. Powered by Jekyll. Hosted with ❤ by GitHub