是的AppDomain等同于.NET code一个过程? [英] Is AppDomain equivalent to a Process for .NET code?

查看:149
本文介绍了是的AppDomain等同于.NET code一个过程?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须调用有内存泄漏和使用单线程公寓[STA]在长时间运行过程中的一些写得很差的第三方COM组件。

I have to call some badly written 3rd party COM components that have memory leaks and uses Single Threaded Apartment [STA] within a long running process.

我知道单独的进程将是很好的方式来实现它,我可以从长时间运行的过程中偶尔会重新启动。

I know separate process will be nice way to implement it and I can restart it occasionally from the long running process.

可以AppDomain中使用呢?是的AppDomain线程STA线程,如果打上appropiately?它有自己的内存为COM对象?正在卸载在AppDomain是相当于杀死进程?

Can AppDomain be used instead? Is AppDomain thread a STA thread if marked appropiately? Does it have its own memory for COM objects? Is unloading the AppDomain is equivalent of killing the process?

推荐答案

这是应用程序域作为一个过程确实不提供隔离的相同程度。事实上,如果你担心第三方组件是不是在良好的状态有一个风险,它会记下你的.NET应用程序。

An AppDomain does not provide the same degree of isolation as a process does. In fact if you're worried that the 3rd party component is not in good shape there's a risk, that it will take down your .NET application.

如果非托管code执行在卸载的时候一个AppDomain无法卸载,所以你可能有一个很难控制的第三方code在一个AppDomain。请参阅<一href="http://msdn.microsoft.com/en-us/library/system.appdomain.unload.aspx">http://msdn.microsoft.com/en-us/library/system.appdomain.unload.aspx

An AppDomain cannot be unloaded if unmanaged code is executing at the time of unload, so you may have a hard time controlling your 3rd party code in an AppDomain. See http://msdn.microsoft.com/en-us/library/system.appdomain.unload.aspx

即使是管理code而已,一个AppDomain不提供强大的沙盒解决方案。例如。如果加载code派生的任何线程,这些将记下的情况下,未处理异常的全过程。这个问题有一点信息:<一href="http://stackoverflow.com/questions/219594/net-whats-the-best-way-to-implement-a-catch-all-exceptions-handler">http://stackoverflow.com/questions/219594/net-whats-the-best-way-to-implement-a-catch-all-exceptions-handler.

Even for managed code only, an AppDomain does not provide a robust sandbox solution. E.g. if the loaded code spawns any threads these will take down the entire process in case of unhandled exceptions. This question has a bit more info: http://stackoverflow.com/questions/219594/net-whats-the-best-way-to-implement-a-catch-all-exceptions-handler.

据我所知主办code一样,在.NET应用程序的最佳选择是实现自己的CLR主机进程如IIS和SQL Server一样。

As far as I am aware the best option for hosting code like that in a .NET application is to implement your own CLR host process like IIS and SQL Server does.

这篇关于是的AppDomain等同于.NET code一个过程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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