Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Blazor Plugins #11463

Closed
dazinator opened this issue Jun 22, 2019 · 5 comments
Closed

Blazor Plugins #11463

dazinator opened this issue Jun 22, 2019 · 5 comments
Labels
area-blazor Includes: Blazor, Razor Components enhancement This issue represents an ask for new feature or an enhancement to an existing one ✔️ Resolution: Duplicate Resolved as a duplicate of another issue
Milestone

Comments

@dazinator
Copy link

dazinator commented Jun 22, 2019

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:

  1. 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.
  2. 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:

  1. 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.

  2. 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.

@mkArtak
Copy link
Contributor

mkArtak commented Jun 22, 2019

Thanks for contacting us, @dazinator.
Have you tried this for unloading assemblies?

@rynowak, is this expected?

the Router never sees that route (because the router only looks at assemblies referenced from the main assembly)

@dazinator
Copy link
Author

@mkArtak
To my knowledge unloadable ALC's are a dotnet core thing, not useable for blazor client side apps which target netstandard 2 running in mono (appdomain driven).. If someone knows better please let me know!

@mkArtak
Copy link
Contributor

mkArtak commented Jun 22, 2019

Seems you're right, @dazinator. Was looking for this in the mono/mono repo and found several threads stating that it's not supported: mono/mono#15011 (comment)

@Eilon Eilon added the area-blazor Includes: Blazor, Razor Components label Jun 22, 2019
@mkArtakMSFT mkArtakMSFT added the enhancement This issue represents an ask for new feature or an enhancement to an existing one label Jun 24, 2019
@mkArtakMSFT mkArtakMSFT added this to the 3.1.0 milestone Jun 24, 2019
@mkArtakMSFT
Copy link
Member

Talked to @rynowak and we'll handle the Router improvement asked for here probably for 3.1 release.

@mkArtakMSFT mkArtakMSFT modified the milestones: 3.1.0, Backlog Aug 12, 2019
@mkArtakMSFT mkArtakMSFT added the ✔️ Resolution: Duplicate Resolved as a duplicate of another issue label Aug 12, 2019
@mkArtakMSFT
Copy link
Member

Actually, we'll track this work as part of #5465

@ghost ghost locked as resolved and limited conversation to collaborators Dec 3, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-blazor Includes: Blazor, Razor Components enhancement This issue represents an ask for new feature or an enhancement to an existing one ✔️ Resolution: Duplicate Resolved as a duplicate of another issue
Projects
None yet
Development

No branches or pull requests

4 participants