Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

asp.net

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

like image 212
Mosh Avatar asked Dec 09 '10 02:12

Mosh


People also ask

Where are DLL files stored in ASP NET application?

ASP.NET applications look in the \bin folder for DLLs, so you can put any DLLs in there. If the DLLs are shared across many applications, however, it may make sense to install in the GAC. (You might need to click the "Show All Files" button at the top of the Solution Explorer to see the \bin folder).

Where are .NET DLL files stored?

DLL files are stored in Bin folder - Basic concept of ASP.NET.

How does. net resolve assembly references?

The runtime uses the following steps to resolve an assembly reference: Determines the correct assembly version by examining applicable configuration files, including the application configuration file, publisher policy file, and machine configuration file.

How. net locates assemblies?

The process of locating an assembly involves the following steps: If a <codeBase> element is found in the application configuration file, the runtime checks the specified location. If a match is found, that assembly is used and no probing occurs. If the assembly is not found there, the binding request fails.


2 Answers

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.

like image 70
Jim Schubert Avatar answered Oct 25 '22 03:10

Jim Schubert


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.

like image 33
Phill Avatar answered Oct 25 '22 01:10

Phill