In a Blazor wasm project I would like to dynamically load a second project without knowing the project at compile time (.Net5). Therefore the normal 'lazy loading' does not work for me. Are there libraries for such purposes? Or an example solution
Asked
Active
Viewed 900 times
0
-
Does this answer your question? [Can I load a .NET assembly at runtime and instantiate a type knowing only the name?](https://stackoverflow.com/questions/465488/can-i-load-a-net-assembly-at-runtime-and-instantiate-a-type-knowing-only-the-na) – gunr2171 Apr 01 '21 at 13:46
-
Hey, it seems like your "Seeking recommendations for books, tools, **software libraries**, and more" (emphasis mine), which is a close reason on Stack Overflow – MindSwipe Apr 01 '21 at 13:47
2 Answers
0
I am also looking for this capability. The static compile time referance in .net 6 is not great.
Have a look at oqtane they were doing some work in lazy loading at runtime back in .net 3.1, unfortunatly it seems that they went more into a nuget direction instead of just dll's https://docs.oqtane.org/index.html https://github.com/oqtane/oqtane.framework/discussions/1076
-
This does not really answer the question. If you have a different question, you can ask it by clicking [Ask Question](https://stackoverflow.com/questions/ask). To get notified when this question gets new answers, you can [follow this question](https://meta.stackexchange.com/q/345661). Once you have enough [reputation](https://stackoverflow.com/help/whats-reputation), you can also [add a bounty](https://stackoverflow.com/help/privileges/set-bounties) to draw more attention to this question. - [From Review](/review/late-answers/31062499) – FlyingFoX Feb 19 '22 at 15:50
0
A little late here but in NET 6 you can do it, I did a Manager where you can look at
https://github.com/elgransan/BlazorPluginComponents
Some example code
var componentPackage = "RazorClassLibrary2";
var component = "Component2";
var stream = await Http.GetStreamAsync($"{MyNavigationManager.BaseUri}/{componentPackage}/{componentPackage}.dll");
var assembly = AssemblyLoadContext.Default.LoadFromStream(stream);
componentType = assembly.GetType(componentPackage + "." + component);
await DOMinterop.IncludeLink(componentPackage, $"/{componentPackage}/{componentPackage}.styles.css");
Where the files are in the server

Santiago
- 2,190
- 10
- 30
- 59