Open Closed

How to consume registered service in the plug-in modules #4723


User avatar
0
raif created
  • ABP Framework version: v7.0.2
  • UI type: MVC
  • DB provider: EF Core
  • Tiered (MVC) or Identity Server Separated (Angular): yes

Hello, We can load module classes as plug-ins without adding reference to project. The relevant explanation is https://docs.abp.io/en/abp/latest/PlugIn-Modules located at here.

Where should we define MyPlugInDemoWebModule class in this example?

using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.Modularity.PlugIns;

namespace MyPlugInDemo.Web
{
    public class Startup
    {
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddApplication<MyPlugInDemoWebModule>(options =>
            {
                options.PlugInSources.AddFolder(@"D:\Temp\MyPlugIns");
            });
        }

        public void Configure(IApplicationBuilder app)
        {
            app.InitializeApplication();
        }
    }
}

This sample code does not seem updated.

Can we replace ConfigureServices(IServiceCollection services) part with

public override void ConfigureServices(ServiceConfigurationContext context)
{

}

and Configure(IApplicationBuilder app) part with

public override void OnApplicationInitialization(ApplicationInitializationContext context)
{
    var app = context.GetApplicationBuilder();
    
    app.InitializeApplication();    
}

More importantly, Can you share an example where we consume a service in a project that we did add as reference

For example, I want to call MyService : IMyService, ITransientDependency that we created in the plug-in


2 Answer(s)
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    I will share a such sample asap.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    https://github.com/abpframework/abp-samples/pull/228

Made with ❤️ on ABP v9.1.0-preview. Updated on December 13, 2024, 06:09