如果ASP.NET加载的混合模式dll具有静态数据,则不会卸载 [英] Mixed Mode dll loaded by ASP .NET is not unloaded if it has static data

查看:57
本文介绍了如果ASP.NET加载的混合模式dll具有静态数据,则不会卸载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个依赖于混合模式MFC C ++程序集的Web Service.

如果使用Web Service,将加载所有dll,并且可以在进程浏览器中看到它们.
然后我对混合模式dll源代码进行更改,并构建Web服务.该生成使IIS卸载程序集(是否卸载AppDomain?).但是混合模式的dll无法卸载.
然后我向Web服务发送请求.它会重新加载所有程序集,因此现在有两个版本的混合模式dll被加载.重复此步骤,最终系统将耗尽内存.

我如何卸载混合模式的dll?我认为它没有卸载,因为它具有静态的本机类数据.我创建了一个原型来证明这一点-并将这样的一行添加到cpp文件中,阻止了它的卸载:

CMyClass myObj; //此行阻止了dll的卸载

但是我不想从真实dll中删除所有静态数据.

还有其他解决方案吗?
/>
谢谢

I have a Web Service that is dependent on a mixed mode MFC C++ assembly.

If I use the Web Service, all the dlls are loaded, and I can see these in process explorer
I then make a change to the mixed mode dll source code, and build the web service. The build causes IIS to unload the assemblies (is it unloading the AppDomain?). However the mixed mode dll does not get unloaded.
I then send a request to the Web Service. It reloads all the assemblies, so now there are two versions of the mixed mode dll loaded. Repeat this and eventually the system will run out of memory.

How can I get the mixed mode dll to unload? I think that it is not unloading because it has static native class data. I created a prototype to prove this - and adding a line like this to a cpp file stopped it from unloading:

CMyClass myObj; // This line stops the dll from unloading

However I don't want to remove all the static data from the real dll.

Are there any other solutions?

Thanks

推荐答案

您在ASP.NET之外也尝试了相同的方法吗? (将这种混合模式的程序集加载到AppDomain中,然后在控制台应用程序中卸载该AppDomain.)这应该显示它是IIS/ASP.NET特定行为还是CLR行为.

如果是IIS/特定于ASP.NET的行为,请在其论坛上提问? http://forums.asp.net
Did you try the same outside of ASP.NET? (Loading such mixed-mode assembly into an AppDomain and unloading the AppDomain in a console app.) That should show if it is IIS/ASP.NET specific behavior or CLR behavior.

If it is IIS/ASP.NET specific behavior, ask on their forums? http://forums.asp.net and http://forums.iis.net.

-Karel


这篇关于如果ASP.NET加载的混合模式dll具有静态数据,则不会卸载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆