Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

c#

.net-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?

like image 718
alireza.salemian Avatar asked Mar 30 '17 01:03

alireza.salemian


1 Answers

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.

like image 135
Sriram Avatar answered Sep 20 '22 01:09

Sriram