profile
viewpoint

Ask questionserror CS1503: Argument 2: cannot convert from 'method group' to 'EventCallback'

Description:

When using EventCallBack<T>, I countered an issue about error CS1503: Argument 2: cannot convert from 'method group' to 'EventCallback'

I have checked other github blogs which related to this, mostly reported that, this has been fixed in preview 7 version. Right now, i have tested with preview 7 build but could not get resolve it.

Here the link which i checked earlier. https://github.com/aspnet/AspNetCore/issues/10077 https://github.com/aspnet/AspNetCore/issues/8385 https://github.com/aspnet/AspNetCore/pull/10730 https://github.com/aspnet/AspNetCore/issues/10077

Whether any syntax changes required to resolve in preview 7 version?

Screenshot: image

Please find my component structure:

Rendering Page [Index razor page]


      @page "/"
      @using GenericEvent.Shared.Models;
      @inject IJSRuntime jsruntime;

    <MyGenComponent Data="@MyData">
        <Events>
        <NonGenericEvents EventTwo="@Event2"></NonGenericEvents>
        <GenericEvents EventOne="@EventOne"></GenericEvents>
         </Events>

    </MyGenComponent>

    @functions {
        public List<string> MyData = new List<string>() { "a", "b", "c", "d" };

        public void Event2(EventArguments args)
       {

       }

       public async Task EventOne(EventArgsData<string> data)
       {
        //dummy call
        await jsruntime.InvokeAsync<string>("call");
       }
      }

MyGenComponent.razor


    @using GenericEvent.Shared.Models;

    @typeparam T;

    <div>
        <ul>
            @ChildContent
        </ul>
    </div>


    @functions {
    [Parameter]
    protected RenderFragment ChildContent { get; set; }

    [Parameter]
    public IEnumerable<T> Data { get; set; }
    }


Events.razor


      @using Microsoft.AspNetCore.Components;

      @inherits ComponentBase



     <CascadingValue Value="@this">
        @ChildContent
    </CascadingValue>

     @functions{

    [Parameter]
    protected RenderFragment ChildContent { get; set; }

    public GenericEvents<object> GenEvents { get; set; }

    public NonGenericEvents NonGenEvents { get; set; }



     }

GenericEvents.razor


      @using Microsoft.AspNetCore.Components;
      @using GenericEvent.Shared.Models;


       @typeparam TValue


      <CascadingValue Value="@this">

     </CascadingValue>


     @functions{
   
     [Parameter]
    public EventCallback<EventArgsData<TValue>> EventOne { get; set; }

    }



NonGenericEvents.razor

   @using Microsoft.AspNetCore.Components;
    @using GenericEvent.Shared.Models;




   <CascadingValue Value="@this">

   </CascadingValue>


   @functions{

     [Parameter]
     public EventCallback<EventArguments> EventTwo { get; set; }


     }

To Reproduce

Clone this Github repository and run the application

https://github.com/gurunathancs1991/BlazorGenericEvents

We are also expecting the solution for this thread too

https://github.com/aspnet/AspNetCore/issues/12116

Additional context


C:\Users\GurunathanA>dotnet --info
.NET Core SDK (reflecting any global.json):
 Version:   3.0.100-preview7-012814
 Commit:    efad165932

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.17763
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\3.0.100-preview7-012814\

Host (useful for support):
  Version: 3.0.0-preview7-27912-14
  Commit:  4da6ee6450

.NET Core SDKs installed:
  1.1.13 [C:\Program Files\dotnet\sdk]
  1.1.14 [C:\Program Files\dotnet\sdk]
  2.1.202 [C:\Program Files\dotnet\sdk]
  2.1.502 [C:\Program Files\dotnet\sdk]
  2.1.602 [C:\Program Files\dotnet\sdk]
  2.1.700 [C:\Program Files\dotnet\sdk]
  2.2.202 [C:\Program Files\dotnet\sdk]
  2.2.300 [C:\Program Files\dotnet\sdk]
  3.0.100-preview7-012814 [C:\Program Files\dotnet\sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.All 2.1.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.1.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.1.11 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.2.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.2.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.1.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.1.11 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.2.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.2.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.0.0-preview4-19216-03 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.0.0-preview7.19363.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 1.0.15 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 1.0.16 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 1.1.12 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 1.1.13 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.0.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.11 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.2.3 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.2.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.0.0-preview4-27615-11 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.0.0-preview7-27912-14 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 3.0.0-preview7-27912-14 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

To install additional .NET Core runtimes or SDKs:
  https://aka.ms/dotnet-download
aspnet/AspNetCore

Answer questions SQL-MisterMagoo

A workaround (maybe even the correct way):

<GenericEvents TValue="string" EventOne="@EventOne"></GenericEvents>
useful!

Related questions

HTTP Error 500.31 - ANCM Failed to Find Native Dependencies hot 123
The SPA default page middleware could not return the default page '/index.html' in production application hot 102
The SPA default page middleware could not return the default page '/index.html' in production application hot 96
Asp.Net MVC Core: “Error unprotecting the session cookie” exception hot 79
No DefaultChallengeScheme found from preview8 to preview9 hot 67
BadHttpRequestException: Reading the request body timed out due to data arriving too slowly hot 65
Method not found: 'Microsoft.EntityFrameworkCore.Metadata.Builders.IndexBuilder Microsoft.EntityFrameworkCore.Metadata.Builders.EntityTypeBuilder`1.HasIndex(System.Linq.Expressions.Expression`1<System.Func`2<System.__Canon,System.Object>>)'. hot 59
The library &#39;hostpolicy.dll&#39; required to execute the application was not found - AspNetCore hot 58
Error: Invocation canceled due to the underlying connection being closed. hot 54
Unexpected end of request content k8s pod - AspNetCore hot 53
Using 'UseMvc' to configure MVC is not supported while using Endpoint Routing. To continue using 'UseMvc', please set 'MvcOptions.EnableEndpointRounting = false' inside 'ConfigureServices'. hot 50
IIS in-process hosting incorrectly throws ConnectionResetException for HTTP POST hot 47
HTTP Error 500.30 - ANCM In-Process Start Failure hot 43
Error: Server returned handshake error: Handshake was canceled. hot 43
Issue with BuildServiceProvider() in ConfigureServices() hot 42
source:https://uonfu.com/
Github User Rank List