【问题标题】:is it possible to unload an Assembly loaded dynamically in dotnet core?是否可以卸载在 dotnet 核心中动态加载的程序集?
【发布时间】:2017-08-23 17:34:45
【问题描述】:

在 .net 框架中,可以在单独的 AppDomain 中加载程序集,然后将其卸载。 在 .net 核心 AppDomain 中不可用并由 AssemblyLoadContext 替换。 我可以将程序集加载到 AssemblyLoadContext 如下:

 var assembly = AssemblyLoadContext.Default.LoadFromStream(stream);

有什么办法可以卸载吗?

【问题讨论】:

标签: c# .net-core


【解决方案1】:

查看此链接here

卸载api尚未完成。

namespace System.Runtime.Loader
{
    public class AssemblyLoadContext
    {
        // Allow to create an unloadable ALC. The default constructor
        // will call this method with false
        protected AssemblyLoadContext(bool unloadable);

        // Returns true if this ALC is collectible
        public bool Unloadable {get; }

        // Allows to explicitly unload an ALC. Once this method is called,
        // any call to LoadFromXXX method will throw an exception
        public void Unload();
    }
}

卸载 api 有一个未解决的问题,该 api 已获批准,可能在未来版本中发布,因为里程碑位于 Future 标签下。

猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-12-03
  • 2010-11-23
  • 1970-01-01
  • 1970-01-01
  • 2011-06-18
相关资源
最近更新 更多