422,139 Members | 1,258 Online
Bytes IT Community
Submit an Article
Got Smarts?
Share your bits of IT knowledge by writing an article on Bytes.

What is Meant by Shadow Copying - in .NET

P: 111
While developing web application I came across build error: "Cannot create/shadow copy 'your assembly info here' when that file already exists". I was not quite sure what is shadow copy is in .net. From name we can guess that its shadowing or helping in taking requests for some thing else. And its correct.

Why this was introduced in asp.net?
If we are developing/updating/enhancing any production applications, without having to stop and restart the web server we can update the server with latest files and the application will not stop or error out at that moment, instead all the requests will be processed with the old files/dlls and any new requestes will be processed with the new dlls/files updated in the server. For this to work shadowing concept was introduced.

The way that this works is that ASP.NET makes a shadow copy of the contents of the \bin directory, and loads the DLLs from the copy. ASP.NET monitors the \bin directory for changes, and repeats the shadow copy when the contents change.

Impact on server by keeping it ON?
It does take time, and if you have a large number of DLLs, or very large DLLs, the shadow copy process can potentially impact application startup and restart performance.

So in some situations, you might want to turn off the shadow copy process. To do this, add the following to your ASP.NET 2.0 web.config file:

<hostingEnvironment shadowCopyBinAssemblies="false" />

Impact of keeping it OFF?
While this will reduce performance overhead associated with shadow copying the contents of the \bin directory, do keep in mind that using this configuration option will result in the DLLs being locked when the app is running. So if you need to update a DLL, you will need to take the application offline or stop the process before you can do so.

Forgot to say you if you get "Cannot create/shadow copy 'your assembly info here' when that file already exists" error, by setting the shadowCopyBinAssemblies="false" we can get rid of this error. We can also remove the error by cleaning the solution (Solution->Clean).

Hope it helps some one.

Bharath Reddy VasiReddy
Apr 7 '10 #1
Share this Article
Share on Google+
1 Comment

P: n/a
Couldnt agree more with that, very attractive article
Nov 22 '10 #2