CodeTherapist / codetherapist.github.io

My Blog
https://codetherapist.com/
0 stars 1 forks source link

blog/netcore3-plugin-system/ #2

Open utterances-bot opened 5 years ago

utterances-bot commented 5 years ago

A plugin system with .NET Core

undefined

https://codetherapist.github.io//blog/netcore3-plugin-system/

chadbr commented 5 years ago

You need a like button :)

Good article -- thanks.

pepperpark commented 5 years ago

Nice article, but why do I need .NET Core 3? All the shown code works also with .NET4 and later, right?

CodeTherapist commented 5 years ago

@chadbr Thank you. I appreciate every feedback - it helps me to stay motivated and delivering more high quality content. Maybe I will add such "like" or "up-vote" functionality 👍

@pepperpark You couldn't use the AssemblyLoadContext in any .NET Framework version - It is only available in .NET Core Framework (1.0 - 3.0). The "unloading feature" of the assembly load context, is only supported from version 3.0 and higher.

nas963 commented 4 years ago

Nice article. I am working on something similar using worker Service template and have problem how to pass arguments to plugin constructor. Concretely I want to pass ILogger and DbContext to plugin constructor using DI. Can you extend your example for this case (passing ILogger from main program to plugin)?

CodeTherapist commented 4 years ago

@nas963 Thanks for your feedback. Good question, sure it is possible to do this - my code is simplified to ensure that also beginner will hopefully understand it. There is already a more advanced library out there that solves this: natemcmaster/DotNetCorePlugins. Thanks @natemcmaster 👍

MithunChopda commented 3 years ago

When you say var pluginFinderAssemblyContext = new PluginAssemblyLoadingContext(name: "PluginFinderAssemblyContext");

What is PluginAssemblyLoadingContext? Did you mean AssemblyLoadContext? Also what is and where is PluginBase?

This article can be truly very useful if you help with the missing pieces.

MithunChopda commented 3 years ago

Also what's in the RegisterPlugin? Can you please add that?

shamrik-dmitriy commented 1 year ago

@MithunChopda Hello! I don't know if this is still relevant to you after all this time, but I'm also learning how to work with plugins.

Obviously, PluginAssemblyLoadingContext is a standard AssemblyLoadContext class. PluginBase is just a base class with a Name field. RegisterPlugin - DI registration method. Thx!