在.net框架中可以在单独的AppDomain中加载程序集然后卸载它.在.net核心AppDomain不可用,并由AssemblyLoadContext取代.我可以将程序集加载到AssemblyLoadContext,如下所示:
var assembly = AssemblyLoadContext.Default.LoadFromStream(stream);
Run Code Online (Sandbox Code Playgroud)
有没有办法卸载它?
在这里查看此链接
卸载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();
}
}
Run Code Online (Sandbox Code Playgroud)
卸载api有一个未解决的问题,并且api已被批准可能在未来版本中发布,因为里程碑在Future标签下.
| 归档时间: |
|
| 查看次数: |
3711 次 |
| 最近记录: |