ASP.Net core web app not unloading other Razor Assembly which were loaded dynamically

90 Views Asked by At

I am having a razor web app where few other razor web app are added dynamically using AssemblyLoadContext

Assembly assembly = _loadContext.LoadFromAssemblyPath(pluginLocation);

Since razor app assembly are added over run time it was required to add assembly to AddApplicationPart. _builder.AddApplicationPart(assembly);

After doing above steps I am able to browse through dynamically added razor web apps.

Issue occurred for when unloading the dynamically added assembly(razor web app).

Steps that I did to unload the assembly(razor web app) are

  • Removed CompiledRazorAssemblyPart and AssemblyPart from ApplicationPartManager
  • Unload AssemblyLoadContext using _loadContext.Unload()
  • Garbage collection using GC.Collect()

Even after doing the above steps dynamically loaded razor web app URL's/pages are accessible. Please suggest a solution to remove the assemblies.

0

There are 0 best solutions below