开发者

Does my ASP.NET application stop executing if I overwrite the DLLs?

开发者 https://www.devze.com 2023-01-29 08:35 出处:网络
Assume that my ASP.NET application is making 开发者_如何学运维4 separate database calls. If after the 2nd call, I overwrite the DLLs in BIN folder, does it stop the application from continuing its pro

Assume that my ASP.NET application is making 开发者_如何学运维4 separate database calls. If after the 2nd call, I overwrite the DLLs in BIN folder, does it stop the application from continuing its processing, hence resulting in the 3rd and 4th database calls being failed?

Any advice would be greatly appreciated, Mosh


ASP.NET performs a thing called shadow copying on various resources including DLLs and ResX files. When a file is accessed by the framework, it is locked preventing direct access. To prevent locking files within the root/bin or root/App*_Resources (for example), it copies these resources to a predetermined directory.

[Edit]
The predetermined directory defaults to something like

C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\demo1\9b9144a7\8665ac07

where demo1 is the name of your application and nested directories which (I assume) are hashed against the friendly name of the AppDomain for the contained resources.

For instance, I have a directory called dbresourceproviderweb from a resource provider example on MSDN written by Michelle Bustamante. Inside that directory, there are two folders: c8b872e2 and 7fc33f08. To go further, compiled resources for Ecuadorian Spanish are under ...\dbresourceproviderweb\c8b872e2\97074f76\es-EC and ...\dbresourceproviderweb\7fc33f08\ac65ebd3\es-EC
[/Edit]

You can change this directory in Application_Start as explained here: AssemblyResolve event is not firing during compilation of a dynamic assembly for an aspx page

You can turn off shadow copying in the web.config:

<hostingEnvironment shadowCopyBinAssemblies="false" />

When one of these shadow copied files is updated within your application, a new AppDomain is spawned and requests in the current AppDomain are allowed to finish while all new requests are directed at the new AppDomain.

For more information on Shadow Copying and AppDomains, check out MSDN's article: http://msdn.microsoft.com/en-us/library/ms404279.aspx

Edit2: I just learned that you can modify the required length of time between file copy operations to spawn an AppDomain.

In the system.web/httpRuntime element, you can specify waitChangeNotification and maxWaitChangeNotification so that a new AppDomain isn't spawned for every file copied. See MSDN.

Although there aren't really examples for this behavior on MSDN, it's good to keep as a reference for the configurability of the HttpRuntime.


The assemblies are loaded into the app domain, and app domain watches the directory, if you replace the assemblies it will recycle the app and reload the assemblies. So yes your 3rd/4th calls would fail.

0

精彩评论

暂无评论...
验证码 换一张
取 消