yiyungent / PluginCore

🔌 ASP.NET Core lightweight plugin framework | ASP.NET Core 轻量级 插件框架 - 一分钟集成 | Vue.js frontend | JavaScript SDK
https://yiyungent.github.io/PluginCore/
GNU Lesser General Public License v3.0
413 stars 81 forks source link

System.TypeLoadException #31

Closed yiyungent closed 8 months ago

yiyungent commented 9 months ago
Unhandled exception. System.TypeLoadException: Method 'ConfigureServices' in type 'UHubPlugin.UHubPlugin' from assembly 'UHubPlugin, Version=0.1.0.0, Culture=neutral, PublicKeyToken=null' does not have an implementation.
   at System.Reflection.RuntimeAssembly.GetExportedTypes()
   at System.Reflection.Assembly.get_ExportedTypes()
   at PluginCore.lmplements.PluginFinder.EnablePluginsFull[TPlugin]()+MoveNext()
   at System.Linq.Enumerable.SelectEnumerableIterator`2.ToArray()
   at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
   at System.Linq.OrderedEnumerable`1.ToList()
   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
   at PluginCore.AspNetCore.Extensions.PluginCoreStartupExtensions.AddPluginCore(IServiceCollection services)
   at KnifeHub.Web.Program.Main(String[] args) in F:\Repos\KnifeHubPro\src\KnifeHub\src\KnifeHub.Web\Program.cs:line 29
yiyungent commented 9 months ago
public void ConfigureServices(IServiceCollection services)

实现

PluginCore.IPlugins.IStartupPlugin.ConfigureServices(IServiceCollection services);

怀疑与 IServiceCollection 有关, 位于 Microsoft.Extensions.DependencyInjection.Abstractions.dll

这通常是被认为成了两个不同的 Type, 于是被判定为没有实现接口

Configure(IApplicationBuilder app)

IApplicationBuilder 位于 Microsoft.AspNetCore.Http.Abstractions.dll ,

可以发现插件 build 后的插件文件夹有这两个 dll, 将其删除,即可让主程序框架认为是同一个 Type ,从而解决