Temporary Shadow Files

Why are the code files for a WCF service running in IIS copied to the Temporary ASP.NET Files folder?

When an assembly file is loaded, that file is locked to prevent changes while the application is running. A service that is running in IIS will continue to run until the application domain is unloaded, which might be an extended period of time until the worker process is recycled. The assembly files remain locked until the service is finally unloaded. This means that the files cannot be updated on disk for substantial periods of time.

Updating the files on disk allows a new version of the service to be prepared while the old version of the service continues to run. Shadow copying allows the assembly files for a service that is in use to be updated without having to stop and unload all of the application domains currently running the service. Shadow copying works by copying the assembly files from the application path to another location prior to being loaded. The original files can then be updated because they are not locked while the service is running.

Using shadow copying requires that the service have permission to read its files from the temporary location. You can disable shadow copying by setting the shadowCopyBinAssemblies attribute of the hosting environment configuration.

Skip to main content