diff --git a/Falcon.SugarApi/Plugin/AssemblyLoadHelp.cs b/Falcon.SugarApi/Plugin/AssemblyLoadHelp.cs
index 7962033..9866370 100644
--- a/Falcon.SugarApi/Plugin/AssemblyLoadHelp.cs
+++ b/Falcon.SugarApi/Plugin/AssemblyLoadHelp.cs
@@ -1,4 +1,5 @@
-using System.IO;
+using System;
+using System.IO;
using System.Reflection;
using System.Runtime.Loader;
@@ -22,6 +23,7 @@ namespace Falcon.SugarApi.Plugin
///
/// 程序集路径
/// 程序集
+ [Obsolete("方法存在问题,程序集注册的对象无法实现注入,目前未解决。使用AssemblyLoad代替",false)]
public static Assembly ALCLoad(string assemblyPath) {
var context = new AssemblyLoadContext(assemblyPath);
return context.LoadFromAssemblyPath(assemblyPath);
diff --git a/Falcon.SugarApi/Plugin/Client/IServiceCollectionExtend.cs b/Falcon.SugarApi/Plugin/Client/IServiceCollectionExtend.cs
index 156a76a..5a6081b 100644
--- a/Falcon.SugarApi/Plugin/Client/IServiceCollectionExtend.cs
+++ b/Falcon.SugarApi/Plugin/Client/IServiceCollectionExtend.cs
@@ -26,6 +26,7 @@ namespace Falcon.SugarApi.Plugin.Client
return;
}
apm.ApplicationParts.Add(part);
+
});
return services;
}
diff --git a/Falcon.SugarApi/Plugin/Service/IServiceCollectionExtend.cs b/Falcon.SugarApi/Plugin/Service/IServiceCollectionExtend.cs
index c8a91c7..c34b6f4 100644
--- a/Falcon.SugarApi/Plugin/Service/IServiceCollectionExtend.cs
+++ b/Falcon.SugarApi/Plugin/Service/IServiceCollectionExtend.cs
@@ -13,6 +13,11 @@ namespace Falcon.SugarApi.Plugin.Service
///
public static class IServiceCollectionExtend
{
+ ///
+ ///
+ ///
+ //public static List Plugins { get; set; } = new List();
+
///
/// 注册插件。
/// 查找插件中的IServicePlugin实现,并运行其中的AddServices方法注册和初始化插件
@@ -26,7 +31,6 @@ namespace Falcon.SugarApi.Plugin.Service
if(name == null) {
return services;
}
- List plugin = new();
var basePath = AppDomain.CurrentDomain.BaseDirectory;
foreach(var pn in pluginNames) {
var pf = pn.EndsWith(".dll") ? pn : pn + ".dll";
@@ -42,12 +46,13 @@ namespace Falcon.SugarApi.Plugin.Service
if(!File.Exists(pf)) {
throw new FileNotFoundException(pf);
}
- var pa = AssemblyLoadHelp.ALCLoad(pf);
+ //var pa = AssemblyLoadHelp.ALCLoad(pf);
+ var pa = AssemblyLoadHelp.AssemblyLoad(pf);
+
if(pa != null) {
- plugin.Add(pa);
+ services.AddPluginService(config,pa);
}
}
- services.AddPluginService(config,plugin.ToArray());
return services;
}