alireza.salemian
alireza.salemian

Reputation: 576

is it possible to unload an Assembly loaded dynamically in dotnet core?

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?

Upvotes: 10

Views: 8287

Answers (1)

Sriram
Sriram

Reputation: 739

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.

Upvotes: 10

Related Questions