dimanche 19 septembre 2021

Disposing Of An Instance from Activator.CreateInstance()

I have software with a plugin system that loads DLL's using Assembly.Load() + Activator.CreateInstance(). The issue that I am having is the fact that the plugin keeps the process open, for example if I close the main window the process still remains open in the background and does not close properly.

My question is, is it possible to remove/unload an instance created by Activator.CreateInstance()? I tried setting the object to null and calling GC.Collect() as suggested in another question, but this was to no avail...

 async public void AddServerModule(Assembly module)
 {
    Type type = module.GetType("ModularModule.ModularModule");
    object instance = Activator.CreateInstance(type, new object[] { this });
    ...
 }




Aucun commentaire:

Enregistrer un commentaire