10

in .net framework was possible to load an assembly in separate AppDomain then unload it. in .net core AppDomain not available and replaced by AssemblyLoadContext. i can load assembly to AssemblyLoadContext as below:

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

there is any way to unload it?

alireza.salemian
  • 536
  • 5
  • 21

1 Answers1

10

Check out this link here

The unload api is not yet completed.

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();
    }
}

there's an open issue for the unload api and the api has been approved probably released in the future version as the milestone is under Future tag.

Sriram
  • 739
  • 7
  • 18
  • 1
    Supported from .NET Core 3.0: https://learn.microsoft.com/en-us/dotnet/standard/assembly/unloadability – EM0 Dec 02 '20 at 14:00