如何卸载从主AppDomain中的组件? [英] How to unload an assembly from the primary AppDomain?

查看:206
本文介绍了如何卸载从主AppDomain中的组件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道如何卸载已加载到主AppDomain中的程序集。

I would like to know how to unload an assembly that is loaded into the main AppDomain.

我有以下的code:

var assembly = Assembly.LoadFrom( FilePathHere );

我需要/希望能够卸载该程序集时,我做了。

I need/want to be able to unload this assembly when I am done.

感谢您的帮助。

推荐答案

您无法从一个AppDomain卸载程序集。你可以破坏应用程序域,但是一旦一个程序集加载到一个AppDomain,它的存在为应用程序域的生命。

You can not unload an assembly from an appdomain. You can destroy appdomains, but once an assembly is loaded into an appdomain, it's there for the life of the appdomain.

请参阅的贾森·詹德的解释为什么没有一个Assembly.Unload方法?

如果您使用的是3.5,则可以使用外接程序框架,使之更易于管理/调用到不同的应用程序域(你的可以的卸载,卸载所有的组件)。如果您使用的是之前的版本中,你需要创建一个新的AppDomain自己卸载它。

If you are using 3.5, you can use the AddIn Framework to make it easier to manage/call into different AppDomains (which you can unload, unloading all the assemblies). If you are using versions before that, you need to create a new appdomain yourself to unload it.

这篇关于如何卸载从主AppDomain中的组件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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