c# - 是否可以卸载在 dotnet 核心中动态加载的程序集?

标签 c# .net-core

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

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

有什么办法可以卸载吗?

最佳答案

查看此链接 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 有一个 Unresolved 问题,该 api 已获得批准,可能会在未来版本中发布,因为里程碑位于 Future 标签下。

关于c# - 是否可以卸载在 dotnet 核心中动态加载的程序集?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43106917/

相关文章:

c# - 仅在按下左键时捕获鼠标移动事件

c# - 如何使用 C# 使表单系统成为模态?

c# - asp.net中办公自动化的问题。如果我知道怎么做,我可以使用开放式办公室等替代方案

rest - .Net Core 和 SSL jet 可以使用 StreamSocket/RESTful/SignalR 作为服务器/客户端吗?

asp.net-core-mvc - 无法生成deps.json以启用迁移

c# - 需要轻量级 .NET SMTP 实现(程序集或源代码)

c# - 寻找一种数据包描述语言(最好使用C#实现)

.net-core - 如何使用当前预览版在 .NET Core 上构建 native 二进制文件?

.net-core - 如何说服 asp.net MVC 静态文件遵循符号链接(symbolic link)

c# - 项目未构建在事件配置中 Visual Studio MacOS .net Core