-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Description
Is your feature request related to a problem? Please describe.
I have been experimenting with loading plugins dynamically into a blazor client app.
Few reasons for this experiment:
- App size can be large. By only allowing assemblies for features that user is interested in using (i.e ones they have enabled), the number of assemblies that need to be loaded into the browser can be kept as low as possible.
- I wanted to see if a kind of "progressive enhancement" was possible. I.e my blazor client app would quickly present an empty shell, which progressively populates as each plugin is then dynamically loaded into it, so the UI builds up in front of you.
I've thrown together a quick POC here with a readme with a few screenshots https://github.com/dazinator/BlazorPlugins
It dynamically loads the plugin from the server when you click the button, and the plugin adds an item to the menu called "weather".
However there are a couple of problem areas I have hit in Blazor that prevent this from being a success endeavour, one which I believe I can work around and another which is a blocker:
-
I can't see a way to unload a plugin assembly, and netstandard2.0 doesn't let me work with the full power of AppDomains i.e no CreateInstanceAndUnwrap() or any of that good old stuff. I beleive I can workaround this problem area though.. when a user enable or disables a plugin, they will have to trigger a reload of the entire app (i.e full page refresh) at which point the shell will load from scratch, but this time only load up the newly approved list of plugins during startup.
-
Blocker: the plugin assembly that I am loading dynamically, includes a Blazor component with the /page directive. However the Router never sees that route (because the router only looks at assemblies referenced from the main assembly) and I am not sure how I can register this assembly with the router.
Describe the solution you'd like
I'd like to see a way to register dynamically loaded assemblies with blazor so that pages and components can be picked up from them. Similar to how we can achieve this with ApplicationParts in MVC.