6K Star 11.8K Fork 4K

GVPdotNET China / Furion

 / 详情

because its signature is not compatible with that of the delegate type

已完成
创建于  
2022-04-22 10:09

💢 特别说明:如果 Issue 没有严格按照模板编写且未提供测试源码下载或 Git 测试仓库地址,则视为无效 Issue

Furion 版本号

3.1.4


Web 项目类型

  • WebApi
  • Mvc
  • Razor Pages
  • Blazor Server
  • MinApp

描述你的问题

事件总线,同一个订阅类下,定义多个方法,只定义一个方法没这个问题,
启动应用报错: Cannot bind to the target method because its signature is not compatible with that of the delegate type

代码

`public class ToDoEventSubscriber : IEventSubscriber, ISingleton
{
private readonly ILogger _logger;
public ToDoEventSubscriber(ILogger logger)
{
_logger = logger;
}

    [EventSubscribe("ToDo:Create")]
    public async Task CreteTodoAsync(EventHandlerExecutingContext context)
    {
        var todo = context.Source;
        _logger.LogInformation($"create a todo item: {todo.Payload}");
        await Task.CompletedTask;
    }

    [EventSubscribe("ToDo:Update")]
    [EventSubscribe("ToDo:Create")]
    public async Task CreateOrUpdateAsync(EventHandlerExecutedContext context)
    {
        var todo = context.Source;
        _logger.LogInformation($"create or update a todo item: {todo.Payload}");
        await Task.CompletedTask;
    }
}` 

异常堆栈信息

在 System.Reflection.RuntimeMethodInfo.CreateDelegateInternal(Type delegateType, Object firstArgument, DelegateBindingFlags bindingFlags)
在 System.Reflection.RuntimeMethodInfo.CreateDelegate(Type delegateType, Object target)
在 Furion.EventBus.EventBusHostedService..ctor(ILogger1 logger, IServiceProvider serviceProvider, IEventSourceStorer eventSourceStorer, IEnumerable1 eventSubscribers)
在 System.RuntimeMethodHandle.InvokeMethod(Object target, Span1& arguments, Signature sig, Boolean constructor, Boolean wrapExceptions) 在 System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) 在 Microsoft.Extensions.DependencyInjection.ActivatorUtilities.ConstructorMatcher.CreateInstance(IServiceProvider provider) 在 Microsoft.Extensions.DependencyInjection.ActivatorUtilities.CreateInstance(IServiceProvider provider, Type instanceType, Object[] parameters) 在 Microsoft.Extensions.DependencyInjection.ActivatorUtilities.CreateInstance[T](IServiceProvider provider, Object[] parameters) 在 Microsoft.Extensions.DependencyInjection.EventBusServiceCollectionExtensions.<>c__DisplayClass1_0.<AddEventBus>b__0(IServiceProvider serviceProvider) 在 Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
在 Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitRootCache(ServiceCallSite callSite, RuntimeResolverContext context)
在 Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor2.VisitCallSite(ServiceCallSite callSite, TArgument argument) 在 Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitIEnumerable(IEnumerableCallSite enumerableCallSite, RuntimeResolverContext context) 在 Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
在 Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitRootCache(ServiceCallSite callSite, RuntimeResolverContext context)
在 Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor2.VisitCallSite(ServiceCallSite callSite, TArgument argument) 在 Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.Resolve(ServiceCallSite callSite, ServiceProviderEngineScope scope) 在 Microsoft.Extensions.DependencyInjection.ServiceProvider.CreateServiceAccessor(Type serviceType) 在 System.Collections.Concurrent.ConcurrentDictionary2.GetOrAdd(TKey key, Func`2 valueFactory)
在 Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(Type serviceType, ServiceProviderEngineScope serviceProviderEngineScope)
在 Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(Type serviceType)
在 Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetService[T](IServiceProvider provider)
在 Microsoft.Extensions.Hosting.Internal.Host.d__12.MoveNext()
在 System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
在 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
在 System.Runtime.CompilerServices.ConfiguredTaskAwaitable.ConfiguredTaskAwaiter.GetResult()
在 Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.d__4.MoveNext()
在 System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
在 Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.d__4.MoveNext()
在 System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
在 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
在 System.Runtime.CompilerServices.TaskAwaiter.GetResult()
在 Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.Run(IHost host)
在 Microsoft.AspNetCore.Builder.WebApplication.Run(String url)
在 Program.$(String[] args) 在 F:\testapplication\dotnet\FurStartApp\FurStartApp\Program.cs 中: 第 39 行


数据库信息

  • Sqlite
  • SqlServer
  • Mysql
  • Oracle
  • PGSql
  • Firebird
  • Cosmos

评论 (1)

CheckyChen 创建了任务
百小僧 任务状态待办的 修改为已完成

登录 后才可以发表评论

状态
负责人
里程碑
Pull Requests
关联的 Pull Requests 被合并后可能会关闭此 issue
分支
开始日期   -   截止日期
-
置顶选项
优先级
参与者(2)
974299 monksoul 1578937227
C#
1
https://gitee.com/dotnetchina/Furion.git
git@gitee.com:dotnetchina/Furion.git
dotnetchina
Furion
Furion

搜索帮助