如何卸载从主AppDomain中的组件?

编程入门 行业动态 更新时间:2024-10-25 14:24:59
本文介绍了如何卸载从主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中的组件?

本文发布于:2023-11-13 10:27:56,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1584126.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:组件   AppDomain

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!