Base solution for your next web application
Open Closed

How to use the third party assembly in plugIns? #2513


User avatar
0
goldstar25 created

I has enable PlugInSources:

return services.AddAbp<AdminWebMvcModule>(options =>
            {
                var plusPath = Path.Combine(_hostingEnvironment.WebRootPath, "PlugIns");
                if (!Directory.Exists(plusPath))
                    Directory.CreateDirectory(plusPath);
                options.PlugInSources.AddFolder(plusPath);
            });

But in plus assembly when I reference a third party assembly,It's not work,and throw NotFound,Only if I move it to site bin folder. And in plus assembly,when I reference orther plus assembly where in PlugIns folder ,it also throw NotFound. Is there any way to solve it?


11 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    Normally this is possible. Which assembly do you try ? Can you send it to <a href="mailto:[email protected]">[email protected]</a> ?

    Also, the assembly in the PlugIns folder must not be referenced in the project.

  • User Avatar
    0
    goldstar25 created

    <cite>ismcagdas: </cite> Hi,

    Normally this is possible. Which assembly do you try ? Can you send it to <a href="mailto:[email protected]">[email protected]</a> ?

    Also, the assembly in the PlugIns folder must not be referenced in the project.

    My run environment is .NET Core. I referenced Magicodes.Sms.Alidayu.Core,you can get it from nuget.I think plus assembly in plus folder can't referenced any assembly ,Including other plugins assembly.

    I find a method "GetAdditionalAssemblies",Do not know if there is any use?

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    I have tried this scenario and it didn't throw any exception for me.

    • I have referenced this package to my web project <a class="postlink" href="http://www.nuget.org/packages/Magicodes.Sms.Alidayu.Core/">http://www.nuget.org/packages/Magicodes ... dayu.Core/</a>.
    • Then copied it's dll to PugIns folder.
    • Then I removed nuget package from my project.

    Can you try it in this way ?

    And your project's Target Framework must be .Net Framework 4.6.1

  • User Avatar
    0
    goldstar25 created

    <cite>ismcagdas: </cite> Hi,

    I have tried this scenario and it didn't throw any exception for me.

    • I have referenced this package to my web project <a class="postlink" href="http://www.nuget.org/packages/Magicodes.Sms.Alidayu.Core/">http://www.nuget.org/packages/Magicodes ... dayu.Core/</a>.
    • Then copied it's dll to PugIns folder.
    • Then I removed nuget package from my project.

    Can you try it in this way ?

    And your project's Target Framework must be .Net Framework 4.6.1

    1. I Add a project name's "Magicodes.Abp.Sms.Application",and referenced this package " Magicodes.Sms.Alidayu.Core" from nuget,this is project.json:
    {
      "version": "1.0.0-*",
    
      "dependencies": {
        "Abp": "1.2.1",
        "Magicodes.Abp.Sms.Core": "1.0.0-*",
        "Magicodes.Admin.Application": "1.0.0.0-*",
        "Magicodes.Sms.Alidayu.Core": "1.0.4"
      },
    
      "frameworks": {
        "net461": {}
      }
    }
    
    1. I copy these dlls to web project’s "wwwroot\PlugIns" folder:

    Magicodes.Abp.Sms.Core.dll Magicodes.Sms.Alidayu.Core.dll Magicodes.Sms.Core.dll

    1. I run this project,and get this exception:
    AbpInitializationException: Could not get module types from assembly: Magicodes.Sms.Alidayu.Core, Version=1.0.4.0, Culture=neutral, PublicKeyToken=null
    Abp.PlugIns.FolderPlugInSource.GetModules()
    Abp.PlugIns.PlugInSourceExtensions.GetModulesWithAllDependencies(IPlugInSource plugInSource)
    System.Linq.Enumerable+<SelectManyIterator>d__16.MoveNext()
    System.Linq.Enumerable+<DistinctIterator>d__63.MoveNext()
    System.Collections.Generic.List..ctor(IEnumerable<T> collection)
    System.Linq.Enumerable.ToList<TSource>(IEnumerable<TSource> source)
    Abp.Modules.AbpModuleManager.FindAllModuleTypes(out List<Type> plugInModuleTypes)
    Abp.Modules.AbpModuleManager.LoadAllModules()
    Abp.AbpBootstrapper.Initialize()
    Abp.AspNetCore.AbpApplicationBuilderExtensions.UseAbp(IApplicationBuilder app)
    Magicodes.Admin.Web.Startup.Startup.Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) in Startup.cs
    +
                app.UseAbp(); //Initializes ABP framework.
    System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
    Microsoft.AspNetCore.Hosting.ConventionBasedStartup.Configure(IApplicationBuilder app)
    Microsoft.AspNetCore.Hosting.Internal.WebHost.BuildApplication()
    

    so I think orthers dll no AbpModule can't put in plus folder. even if can put in this folder,will not find it.

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    Have you tried to remove these three lines from project.json before running the project ?

    "Magicodes.Abp.Sms.Core": "1.0.0-*",
    "Magicodes.Admin.Application": "1.0.0.0-*",
    "Magicodes.Sms.Alidayu.Core": "1.0.4"
    
  • User Avatar
    0
    goldstar25 created

    It's Ok and no exception.but if I not referenced these dlls ,I can't use these dlls in plus project.

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    Probably I understand you wrongly. If you are referencing this dll via nuget package, why do you need to copy it into PlugIns folder ?

    Can you explain it in a bit more detailed.

    Thanks.

  • User Avatar
    0
    goldstar25 created

    <cite>ismcagdas: </cite> Hi,

    Probably I understand you wrongly. If you are referencing this dll via nuget package, why do you need to copy it into PlugIns folder ?

    Can you explain it in a bit more detailed.

    Thanks.

    I want dynamic loading plugin assembly,but if plugin project referenced orther project or orther assembly,It will not work.I do not know how to deal with it,Hope you can give pointers.

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    Sorry, I didn't understand you at the beginning very well but now I understand it. For now you need to use copying dll's to bin folder solution. I have created an issue for this problem here <a class="postlink" href="https://github.com/aspnetboilerplate/aspnetboilerplate/issues/1892">https://github.com/aspnetboilerplate/as ... ssues/1892</a>. We will fix it in the next versions.

    Thanks for your patience.

  • User Avatar
    0
    goldstar25 created

    Thanks.My English is so so.

  • User Avatar
    0
    ismcagdas created
    Support Team

    No it is my fault, you explained it in the beginning very well :).

    Thanks again.