1

i was only able to read up that ASP.NET detects changes to specific files like aspx files, DLLs and others. It will restart itself, finish current running requests and new requests with the new deployed files.

But what is happening in the time from the first file beeing copied till the last one has been exchanged? If i exchange the first DLL file, then a request comes in but the other DLL files are in an older version - will it just crash? Will asp.net wait for some seconds and only starts itself new after X seconds of no (relevant) file changes?

Thx!

4

1 回答 1

2

您在这里有 4 个问题: 从第一个文件被复制到最后一个文件被交换的这段时间内发生了什么?- .net 在启动新的应用程序域并加载新的 dll 之前等待查看是否有任何其他文件已被修改,有一个设定的时间。

如果我交换第一个 DLL 文件,那么会收到一个请求,但其他 DLL 文件是旧版本 - 它会崩溃吗?- 这取决于 dll 中的代码更改。如果新的 dll 可以与旧代码一起正常运行,那就没问题了。但是,如果应用程序域启动了新的 DLL,并且新的 dll 依赖于尚不存在的东西……那么是的,它会抛出异常。

asp.net 会等待几秒钟,并且仅在 X 秒没有(相关)文件更改后才重新启动?- 是的。我一直找不到那个时间有多长。但根据我个人的经验,它在 1-2 秒范围内。

我还在这里找到了关于应用程序域和重新加载 DLL 的一个很好的解释:http: //odetocode.com/Articles/305.aspx

如果将更新的 dll 复制到应用程序的 bin 子目录中,ASP.NET 运行时会识别出有新代码要执行。由于 ASP.NET 无法将 dll 交换到现有的 AppDomain 中,因此它会启动一个新的 AppDomain。旧的应用程序域是“drain stop”的,即允许现有请求完成执行,一旦它们全部完成,AppDomain 就可以卸载。新的 AppDomain 以新代码开始并开始接受所有新请求。

通常,当 dll 加载到进程中时,进程会锁定 dll,您无法覆盖磁盘上的文件。但是,AppDomains 有一个称为 Shadow Copy 的功能,它允许程序集在磁盘上保持解锁和可替换状态。

运行时初始化 ASP.NET,并为 bin 目录启用卷影复制。AppDomain 会将它需要的任何 dll 从 bin 目录复制到一个临时位置,然后再将 dll 锁定并加载到内存中。Shadow Copy 允许我们在更新期间覆盖 bin 目录中的任何 dll,而无需使 Web 应用程序脱机。

于 2010-04-06T16:52:42.337 回答