Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Modular functionality with ASP.NET vNext Core CLR

With ASP.NET 4.5 it is possible to use Assembly.Load() or AppDomain.CurrentDomain.Load() to dynamically load an assembly at runtime. This can be used to add new functionality to a running web application in the form of modules without having to rebuild or even restart the app.

I would like to know how this can be done with the new ASP.NET vNext (5.0?) targeting the Core framework. I know this can be done with the full framework as System.AppDomain is available along with an overloaded Assembly.Load(). When I change to target the Core framework, I no longer have System.AppDomain available and Assembly.Load() becomes limited.

Is there a way to get this dynamic modular functionality in the ASP.NET 5.0 Core framework?

like image 885
Tom Avatar asked Dec 08 '14 16:12

Tom


2 Answers

I'm not sure what a good answer would be, because Asp.Net 5 is so new, and doesn't have a lot of full documentation.

It should theoretically be possible, it'll just be different than what you're used to.

Looking at the source there is an interface IAssemblyLoadContext which will allow you to get the assembly. There is also IAssemblyLoader.

These are used by the "kre" host, which is the underlying piece of Asp.Net 5 that basically boostraps your application. So you would need to add your IAssemblyLoader to the underlying host, so that the kre.

Unfortunately I'm not seeing very many extension points in the code as of yet. Will we be getting those extension points? I do not know. You can log an issue on the github page. It's also possible there is an extension point I'm not seeing currently.

To come back to the question, can you add that kind of extensiblity to Asp.Net 5 Core? Yes, you could create your own host, similar to the default host, that would then include your custom loader, and then start your application with that.

like image 89
David Driscoll Avatar answered Nov 07 '22 12:11

David Driscoll


You can try ExtCore framework

It allows to have modular and extendable ASP.NET 5 applications out of the box.

In short

  1. It allows to use both modules from dlls and from nuget packages at the same time.
  2. It allows all modules to work with storage in the single context and to have their own models and repositories.
  3. Every extension can have controllers, views, static content etc.
like image 34
Oleh Dokuka Avatar answered Nov 07 '22 12:11

Oleh Dokuka