Aspnetboilerplate: Automatically add plugin assemblies to ApplicationParts for AspNet Core

Created on 19 Nov 2016  路  3Comments  路  Source: aspnetboilerplate/aspnetboilerplate

Hello Halil, I麓m trying create plugin using ASP.NET core version of ABP, and I have problem with Controllers. In documentation you wrote workaround to investigate controllers for classic ASP.NET. How to solve this in ASP.NET CORE ?.

I have plugin project, with controller folder and CatalogController.cs class, class derive from AbpController.
Plugin has also some views..

When i create reference manualy (add reference of CatalogModule to Web project and add CatalogModule type to depends on attribute everythink is OK.

Whne I remove this reference and attribute and use this code for load catalog module dynamicly, controllers in module not work. What I麓m doing wrong ? Do anybody try to use plugins with Controllers in ASP.NET CORE ? Thanks for help!

            //Configure Abp and Dependency Injection
            return services.AddAbp<BrunoWebModule>(options =>
            {

                var moduleAbsolutePath = Path.Combine(_hostingEnvironment.ContentRootPath, "Modules");
                options.PlugInSources.Add(new FolderPlugInSource(moduleAbsolutePath, SearchOption.AllDirectories));

                //Configure Log4Net logging
                options.IocManager.IocContainer.AddFacility<LoggingFacility>(
                    f => f.UseAbpLog4Net().WithConfig("log4net.config")
                );
            });
enhancement

Most helpful comment

ABP current does nothing to add your assemblies as application part to ASP.NET MVC. But we can do it. The only problem is that: ABP does not know if this assembly contains MVC Controllers. If it adds all assemblies to AddApplicationPart method, then this would be a small startup performance problem since MVC scans all application part assemblies to find controllers.
To solve this issue, we may add an option to let ABP know it. I'll think on that.

All 3 comments

I solved this by:

            foreach (var module in Modules)
            {
                // Register controller from modules
                mvcBuilder.AddApplicationPart(module.Assembly);
            }

but I need to manualy find and load module assemblies in Startup class.

ABP current does nothing to add your assemblies as application part to ASP.NET MVC. But we can do it. The only problem is that: ABP does not know if this assembly contains MVC Controllers. If it adds all assemblies to AddApplicationPart method, then this would be a small startup performance problem since MVC scans all application part assemblies to find controllers.
To solve this issue, we may add an option to let ABP know it. I'll think on that.

Thanks!

Was this page helpful?
0 / 5 - 0 ratings