C
C#7mo 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
TheSnowOwl7mo 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 McCheese7mo 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
333fred7mo ago
ALCs are the new way. That's your only option in modern dotnet
Denis
Denis6mo ago
What is ALC?
333fred
333fred6mo ago
AssemblyLoadContext, as was mentioned in the op
Denis
Denis6mo ago
Ah, thanks a lot
TheSnowOwl
TheSnowOwl6mo ago
i see, how would i go about actually unloading assemblies loaded in one then?
Want results from more Discord servers?
Add your server
More Posts
EFCore 8 - Owned type with navigation property not being includedHello, i have an issue with EFCore (or maybe it's just me being pepega), but i have a class Score thSqlBulkCopy IListWhat frameworks are available for performing bulk copy using an `IList` as the input? There's `DataUsing base class as relationship definition in model ASP.net WEB APISo I've written this model that I used to save my credentials to authenticate my users with: ```cshhow to join will null?I have this logic: ```cs private async Task OnChannelsGet( IDeliveryHandlerContext context, ✅ Ensure that subclasses all have to override a specific method?Is it possible to define a method in a class to say that it *must* be defined in every subclass? FoAnyone from Ukraine here? Recommend any remote Ukrainan/russian speaking companies for junior/mediorAnyone from Ukraine here? Recommend any remote Ukrainan/russian speaking companies for junior/medior✅ WPF Datagrid colums widthHi, any idea why my column do not fit the whole width of my datagrid ? https://paste.mod.gg/csupsvqClass library is not found while building the ASP.NET Core 7 Web API with Github ActionsI wrote this dotnet.yml to build my application and push the docker image to docker hub, placed in thow to to register multiple Entity Framework Core database providershow to to register multiple Entity Framework Core database providers (Microsoft.EntityFrameworkCore.Am I understanding .NET Framework correctly?1st year CS student writing a report on why I choose C# over other languages in game development, in