C
C#12mo ago
TheSnowOwl

What is a good way of loading and unloading an assembly at runtime?

im making a system that should be able to load an assembly, run code from it, and then be able to unload it. currently im using AssemblyLoadContext, however that requires all references to be destroyed before it can unload. is there a better way of loading it? and if not, how do i completely destroy a reference to an object given i am 100% sure i have just one place where i have the instance?
8 Replies
TheSnowOwl
TheSnowOwlOP12mo ago
i see, but such static generic classes will only be a thing once they are called, am i right? someone told me recently that there was a newer better way to load assemblies at runtime than AssemblyLoadContext, however they couldnt tell me more than that they knew a new way existed, perhaps you know cri guess ill have to search further thanks for your time
Mayor McCheese
Mayor McCheese12mo ago
What's wrong with an assembly load context, they support unloading. Though to the point @univershal SyncRооt makes, there could be some potential problems with unloading.
333fred
333fred12mo ago
ALCs are the new way. That's your only option in modern dotnet
Denis
Denis12mo ago
What is ALC?
333fred
333fred12mo ago
AssemblyLoadContext, as was mentioned in the op
Denis
Denis12mo ago
Ah, thanks a lot
TheSnowOwl
TheSnowOwlOP12mo ago
i see, how would i go about actually unloading assemblies loaded in one then?
Want results from more Discord servers?
Add your server