Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我对按需加载许多动态程序集感兴趣。
由于所有这些模块都可能产生太大的内存压力,因此我想在操作系统指示或检测到缺乏活动时卸载它们。
如何卸载以前加载的模块?退出应用程序是唯一的方法吗?
您无法卸载以前加载的模块。
briannoyes 说:
这是 .NET 的限制,一旦加载程序集,就无法卸载它,除非您重新启动进程或将其加载到单独的应用程序域中,这会打开一整套单独的蠕虫病毒,我们决定不在 Prism 中追踪1.
资源
您可以尝试让未使用的对象被垃圾收集,并且不要将它们保存在静态容器中。