Alok
Alok

Reputation: 828

Does Autofac provides means to load unload plugin with services/middleware on runtime?

I am new to autofac and using .net 5-6 in my projects, i built my app in different modules which are loaded in app startup (using alc). But i was wondering if its possible with autofac to load/unload these full app plugins on runtime. much like how wordpress etc. are designed.

you load a zip file with all the plugin dll/files and it manages the info of it on runtime? including services & middlewares initialization.

Upvotes: 0

Views: 209

Answers (1)

Travis Illig
Travis Illig

Reputation: 23894

Autofac does not perform the jobs of assembly loading, plugin management, etc. That's up to your application code. If you have your plugins managed as zip files or folders full of assemblies or whatever, it's up to your application to:

  • Perform any file operations - unzip, move, locate.
  • Load the assemblies into memory - Assembly.Load or whatever.
  • Handle any reference problems that the runtime doesn't already handle - missing dependency assemblies, etc.

You can then use the standard Autofac interfaces to make your registrations.

The point is, Autofac isn't a plugin framework it's a DI container. Anything outside of DI is up to you. Even if you're thinking about the assembly scanning logic, Autofac isn't loading or locating the assemblies - it's just scanning assemblies you've already loaded.

Upvotes: 0

Related Questions