如何卸载在IronPython的.NET程序集引用 [英] How to unload a .NET assembly reference in IronPython
问题描述
加载引用程序集的东西,如后:
After loading a reference to an assembly with something like:
import clr
clr.AddRferenceToFileAndPath(r'C:\foo.dll')
我怎么能再次卸载组件?
How can I unload the assembly again?
为什么会有人想这样做?因为我重新编译 foo.dll
并要重新加载它,但是编译器是给我大惊小怪,因为IronPython的是媒体链接访问 foo.dll
。
Why would anyone ever want to do this? Because I'm recompiling foo.dll
and want to reload it, but the compiler is giving me a fuss, since IronPython is allready accessing foo.dll
.
推荐答案
.NET本身并不支持卸载只是一个单一的组件。相反,你需要卸载整个的AppDomain
。我不知道确切的IronPython如何与的AppDomain
S,但是这是做事的正常.NET方式。 (程序集加载到一个新的的AppDomain
,使用,废弃的AppDomain
,创建一个新的的AppDomain
与文件等的新版本。)
.NET itself doesn't support unloading just a single assembly. Instead, you need to unload a whole AppDomain
. I don't know exactly how IronPython works with AppDomain
s, but that's the normal .NET way of doing things. (Load the assembly into a new AppDomain
, use it, discard the AppDomain
, create a new AppDomain
with the new version of the file etc.)
这篇关于如何卸载在IronPython的.NET程序集引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!