SimplCommerce
SimplCommerce copied to clipboard
Refactoring module loading (maybe just clarify)
I figured out a bit about loading modules here and in .NET Core in general. It seems to the flag IsBundledWithHost
in current implementation redundant.
There are currently two ways to load modules:
Assembly.Load(new AssemblyName(module.Id));
and
AssemblyLoadContext.Default.LoadFromAssemblyPath(file.FullName);
apparently implied that Assembly.Load
if IsBundledWithHost
set true
and AssemblyLoadContext.Default.LoadFromAssemblyPath
if set false
.
But from what I understand these two methods lead to the same result. They are all load plugins with dependence in default context i.e. AssemblyLoadContext.Default
. https://github.com/richlander/dotnet-core-assembly-loading
Do I understand correctly that the code has not been completed yet ? If this part is already completed maybe it will be better to clean up the excess ? But maybe I'm wrong and I didn't understand something .
Oh, It seems I got it, IsBundledWithHost
mean that WebHost just has references on related modules.
I understand correctly?
In this case it seams to me it will be more convenient implement your own AssemblyLoadContext
with AssemblyDependencyResolver
in case when IsBundledWithHost
is false
i.e. outside of solution.
I think you right. And I think in the case IsBundledWithHost is false, you must publish your module to folder and locate it in Modules folder to try load it. But when I try to publish a module, it product nugetpackage => so I think it cannot to use this feature now, otherwise find solution to publish it as DLL.
I think you right. And I think in the case IsBundledWithHost is false, you must publish your module to folder and locate it in Modules folder to try load it. But when I try to publish a module, it product nugetpackage => so I think it cannot to use this feature now, otherwise find solution to publish it as DLL.
yes, DLL is exactly what I meant, like a plugin system I think now there are no obstacles to publich modules as DLL and most likely it will be quite easy to make a plugin system on this project
Yes, you are. pls take a look at: https://docs.simplcommerce.com/developer-guide/how-to-add-new-modules.html Hope to help you!