ASP.NET 如何处理部署

发布于 2024-08-20 21:43:47 字数 224 浏览 8 评论 0原文

我只能了解到 ASP.NET 检测到特定文件(如 aspx 文件、DLL 等)的更改。它将自行重新启动,完成当前正在运行的请求以及使用新部署的文件的新请求。

但是从第一个文件被复制到最后一个文件被交换期间发生了什么?如果我交换第一个 DLL 文件,则会收到请求,但其他 DLL 文件是旧版本 - 它会崩溃吗? asp.net 是否会等待几秒钟,并且仅在 X 秒没有(相关)文件更改后才重新启动?

谢谢!

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!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

彻夜缠绵 2024-08-27 21:43:47

您在这里有 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
已停止”,即现有请求
允许完成执行,并且
一旦他们都完成了
AppDomain 可以卸载。新的
AppDomain 以新代码开始,
开始接受所有新请求。

通常,当 dll 加载到
进程,进程锁定dll并且
您无法覆盖磁盘上的文件。
然而,AppDomains 有一个功能
称为卷影复制,允许
组件保持解锁状态并且
可在磁盘上替换。

运行时初始化 ASP.NET
为 bin 启用卷影复制
目录。 AppDomain 将复制任何
bin目录下需要的dll
锁定前的临时位置
并将dll加载到内存中。
卷影复制允许我们覆盖任何
dll 在 bin 目录中
无需网络即可更新
离线应用程序。

You have 4 questions here:
What is happening in the time from the first file beeing copied till the last one has been exchanged? - There is a set time while .net waits to see if any other files have been modified before it starts up the new app domain with the new dll's loaded.

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? - It depends on what code changes are in the dll's. If the new dll can run fine with old code then it will be fine. But if the app domain spins up the new DLL and that new dll is dependent on something that isn't there yet... then yes it will throw an exception.

Will asp.net wait for some seconds and only starts itself new after X seconds of no (relevant) file changes? - Yes. I haven't been able to find how long that time is. But in my personal experience it's somewhere in the 1-2 second range.

I also found a good explanation here on app domain and re-loading of DLL's:
http://odetocode.com/Articles/305.aspx

If you copy an updated dll into an
application’s bin subdirectory, the
ASP.NET runtime recognizes there is
new code to execute. Since ASP.NET
cannot swap the dll into the existing
AppDomain , it starts a new AppDomain.
The old application domain is “drain
stopped”, that is, existing requests
are allowed to finish executing, and
once they are all finished the
AppDomain can unload. The new
AppDomain starts with the new code and
begins taking all new requests.

Typically, when a dll loads into a
process, the process locks the dll and
you cannot overwrite the file on disk.
However, AppDomains have a feature
known as Shadow Copy that allows
assemblies to remain unlocked and
replaceable on disk.

The runtime initializes ASP.NET with
Shadow Copy enabled for the bin
directory. The AppDomain will copy any
dll it needs from the bin directory to
a temporary location before locking
and loading the dll into memory.
Shadow Copy allows us to overwrite any
dll in the bin directory during an
update without taking the web
application offline.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文