问题描述
当我从Visual Studio的加载项菜单中删除加载项时,它不会从内存中卸载。有谁知道我是否可以为我的加载项(在C#中)编写一些代码来强制卸载。
When I remove an add-in from Visual Studio's add-in menu, it doesn't get unloaded from memory. Does anyone know if I can write some code for my add-in (in C#) that would force this unloading. Is this even possible, or do I have to restart VS?
推荐答案
如果您的DLL是用托管代码编写的,那是不可能的吗?强制将其作为Visual Studio加载项卸载。 CLR不支持这种机制。
If your DLL is written in managed code there is no way to force it to be unloaded as a Visual Studio Add-In. The CLR does not support such a mechanism.
迫使DLL从进程中卸载的唯一方法是拆除所有已加载DLL的AppDomain。在Visual Studio加载项方案中,加载项将被加载到默认的AppDomain中。消除这种情况需要拆除整个过程:(
The only way to force a DLL to be unloaded from a process is to tear down all AppDomains which have loaded the DLL. In a Visual Studio Add-In scenario, the add-in will be loaded into the default AppDomain. Tearing this down necessitates tearing down the entire process :(
这篇关于Visual Studio和加载项卸载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!