简体   繁体   English

更改web.config会卸载ASP.NET应用程序,但不会“足够”地卸载

[英]Changing web.config unloads ASP.NET application, but doesn't unload “enough”

We have an ASP.NET web application, which is a C# DLL , that references a C++/CLI DLL , that links against some native static libs. 我们有一个ASP.NET Web应用程序,它是一个C#DLL ,它引用一个C ++ / CLI DLL ,该DLL链接到某些本机静态库。

When we edit the web.config file, the appdomain unloads itself as expected, however at the next web request the application crashes with some access violation exception from our native code. 当我们编辑web.config文件时,appdomain会按预期卸载自己,但是在下一个Web请求时,应用程序崩溃了,并且本机代码中出现一些访问冲突异常。

Further investigation has shown that as soon when the app domain "unloads", the w3wp.exe process actually lives on , and it only unloads our C# DLL (and not our C++/CLI DLL). 进一步的研究表明,当应用程序域“卸载”时, w3wp.exe进程实际上就存在于 ,并且它仅卸载我们的C#DLL(而不是我们的C ++ / CLI DLL)。 This is probably why we're getting these exceptions. 这可能就是为什么我们遇到这些异常的原因。

How can we stop this madness? 我们怎样才能制止这种疯狂? Can we get ASP.NET to completely recycle the w3wp process upon web.config update? 我们可以让ASP.NET在web.config更新时完全回收w3wp进程吗? Can we get ASP.NET to actually unload all of our DLLs if w3wp lives on? 如果w3wp继续存在,我们能否让ASP.NET实际卸载所有DLL?

Create a wrapper assembly and manually GetModuleHandle + FreeLibrary when the assembly / appDomain is recycled. 创建包装程序集,并在回收程序集/ appDomain时手动创建GetModuleHandle + FreeLibrary。

It would cause problems if you create Application Domains manually or use one Application Pool in IIS for multiple applications, though. 但是,如果您手动创建应用程序域或将IIS中的一个应用程序池用于多个应用程序,则可能会导致问题。

除了在Application_End的末尾调用Environment.Exit(0) ,找不到更好的解决方案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM