Thursday, August 18, 2011

Cannot create/shadow copy when that file already exists


Solution 1 : Clean the solution and rebuild and it will work fine then.


Solution 2 : If this happens frequently you can add the following in web.config or app.config

<system.web>
   <hostingEnvironment shadowCopyBinAssemblies="false" />
</system.web>


Note : Shadow Copy is a ASP.NET feature enabled on every appdomain. Usually loadded assemblies
will be copied to a shadow copy cache directory, and from there it will be used so that the original file is not locked.