ASP.Net cannot create/shadow copy in PRODUCTION
Asked Answered
C

2

16

We've recently updated a fairly large ASP.NET website (~1500th alexa traffic ranking) to use VS2010 and .NET 4.0 running on Windows Server 2008 R2

Since then, when we deploy new versions of the site we occasionally noticed the same error in this post: ASP.Net cannot create/shadow copy The error message is: Cannot create/shadow copy 'xxxx, Version=4.0.4301.26898, Culture=neutral, PublicKeyToken=null' when that file already exists

However, unlike in that post, the error is occurring only in our production environments & only on some servers.

After we ship a new version of the code, we recycle all AppPools and the error starts occuring.

A further AppPool recycle seems to fix the issue, however I really want to know how we can avoid this problem in the first place?

Customary answered 13/10, 2011 at 20:3 Comment(0)
C
4

We've finally solved our 'Cannot create/shadow copy' problems. The problem turned out to be due to the timing of our AppPool recycle & our directory copies. It worked something like this:

  1. copy main website to: server\directory
  2. recycle app pool for website
  3. copy small admin site to server\otherdirectory

The problem was that our admin site was a virtual directory of the main site and used the same AppPool. This worked fine under .NET 2.0, but I think we can pinpoint the failures to when we upgraded to .NET 4.0. Seems to run just fine if we do it this way instead:

  1. copy main website to: server\directory
  2. copy small admin site to server\otherdirectory
  3. recycle app pool for website
Customary answered 28/11, 2011 at 23:28 Comment(0)
N
4

We found that excluding the temporary asp.net folders from indexing (and virus scanning) eliminated our shadow copy errors.

Example PowerShell script for the indexing service on Windows Server 2003:

Set-ItemProperty –path

HKLM:\SYSTEM\CurrentControlSet\Control\ContentIndex\Catalogs\Web\Scopes -name “C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files” -value ",,4"

Restart-Service cisvc

Nsf answered 11/11, 2011 at 14:3 Comment(2)
We're using Windows Server 2008 R2 and didn't have that registry entry. Thanks for the suggestion though, we'll see if there is something equivalent we can doCustomary
Preventing my AntiVirus software from scanning Temporary ASP.NET Files seems to have done the trick for me.Imputable
C
4

We've finally solved our 'Cannot create/shadow copy' problems. The problem turned out to be due to the timing of our AppPool recycle & our directory copies. It worked something like this:

  1. copy main website to: server\directory
  2. recycle app pool for website
  3. copy small admin site to server\otherdirectory

The problem was that our admin site was a virtual directory of the main site and used the same AppPool. This worked fine under .NET 2.0, but I think we can pinpoint the failures to when we upgraded to .NET 4.0. Seems to run just fine if we do it this way instead:

  1. copy main website to: server\directory
  2. copy small admin site to server\otherdirectory
  3. recycle app pool for website
Customary answered 28/11, 2011 at 23:28 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.