Open Closed

SignalR error: Invocation provides 1 argument(s) but target expects 0 #5147


User avatar
0
cunyong.yu@vskysoft.com created

I've created a component for reading Excel files that works fine in a blank Blazor project, but when I add it to a Blazor project based on ABP Framework, I get an error message saying 'Invocation provides 4 argument(s) but target expects 3.' Could you please help me understand why this happens and how to fix it? Thank you!"

The following is my code.

@page "/upload-excel"
@using System.IO

<Field>
    <FileEdit Changed="@OnChanged" />
</Field>

@code {
    async Task OnChanged(FileChangedEventArgs e)
    {
        try
        {
            var file = e.Files.FirstOrDefault();
            if (file == null)
            {
                return;
            }

            using (MemoryStream result = new MemoryStream())
            {
                await file.OpenReadStream(long.MaxValue).CopyToAsync(result);
            }
        } catch (Exception exc)
        {
            Console.WriteLine(exc.Message);
        } finally
        {
            this.StateHasChanged();
        }
    }
}
  • ABP Framework version: v7.1.0
  • UI type: Blazor
  • DB provider: EF Core
  • Tiered (MVC) or Identity Server Separated (Angular): no
  • Exception message and stack trace:System.IO.InvalidDataException HResult=0x80131501 Message=Invocation provides 4 argument(s) but target expects 3. Source=Microsoft.AspNetCore.Components.Server StackTrace: 在 Microsoft.AspNetCore.SignalR.Protocol.MessagePackHubProtocolWorker.BindArguments(MessagePackReader& reader, IReadOnlyList`1 parameterTypes)
  • Steps to reproduce the issue:"open the page

23 Answer(s)
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    Set EnableDetailedErrors in AddHubOptions to see detail errors.

    builder.Services.AddSignalR(hubOptions =>
     {
         hubOptions.EnableDetailedErrors = true;
     });
    
  • User Avatar
    0
    cunyong.yu@vskysoft.com created

    hi

    Set EnableDetailedErrors in AddHubOptions to see detail errors.

    builder.Services.AddSignalR(hubOptions => 
     { 
         hubOptions.EnableDetailedErrors = true; 
     }); 
    

    I set this in the program. cs of Blazor. Server. Host, but it is still the same error. Where can I go to see the detailed information?

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    Can you share a template project that reproduces the problem?

    liming.ma@volosoft.com

  • User Avatar
    0
    cunyong.yu@vskysoft.com created

    Can you share a template project that reproduces the problem?

    I have sent you an email with a template project attachment, please check it.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    Which project?

  • User Avatar
    0
    cunyong.yu@vskysoft.com created

    Which project?

    AbpBlazorDemo.Blazor.Server.Host.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    Some source files of your project are broken. Please fix it and share again(run abp clean and remove the node_moduels). Thanks

  • User Avatar
    0
    cunyong.yu@vskysoft.com created

    Some source files of your project are broken. Please fix it and share again(run abp clean and remove the node_moduels). Thanks

    Sorry, my project has been encrypted by company software. In fact, this is just an empty ABP module project. You can create one locally and then copy the file "ReadExcel. razor" to open it, which can reproduce the error.

  • User Avatar
    0
    cunyong.yu@vskysoft.com created

    The code for ReadExcel. razor is as follows:

    @page "/upload-excel"
    @using System.IO
    
    `&lt;Field&gt;
        &lt;FileEdit Changed=&quot;@OnChanged&quot; /&gt;
    &lt;/Field&gt;`
    
    @code {
        async Task OnChanged(FileChangedEventArgs e)
        {
            try
            {
                var file = e.Files.FirstOrDefault();
                if (file == null)
                {
                    return;
                }
    
                using (MemoryStream result = new MemoryStream())
                {
                    await file.OpenReadStream(long.MaxValue).CopyToAsync(result);
                }
            } catch (Exception exc)
            {
                Console.WriteLine(exc.Message);
            } finally
            {
                this.StateHasChanged();
            }
        }
    }
    

    This is just a simple function of selecting a local Excel file and reading it.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    I think there is a problem with Blazorise. You can use the asp net core way to upload the files.

    https://learn.microsoft.com/en-us/aspnet/core/blazor/file-uploads?view=aspnetcore-7.0&pivots=server

  • User Avatar
    0
    cunyong.yu@vskysoft.com created

    hi

    I think there is a problem with Blazorise. You can use the asp net core way to upload the files.

    https://learn.microsoft.com/en-us/aspnet/core/blazor/file-uploads?view=aspnetcore-7.0&pivots=server

    I have tried this method and the same error occurred.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    Can you test the code in an opensource template project and share it again?

    abp new BookStore -t module

  • User Avatar
    0
    cunyong.yu@vskysoft.com created

    hi

    Can you test the code in an opensource template project and share it again?

    abp new BookStore -t module

    The new project has been sent to you.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    I have not received it yet.

    liming.ma@volosoft.com

  • User Avatar
    0
    cunyong.yu@vskysoft.com created

    I have not received it yet.

    liming.ma@volosoft.com

    The email has been returned, and the attachment is only 50M in size. Prompt error:the mta server of volosoft.com -- aspmx.l.google.com(142.250.157.26) reply:552 5.2.3 Your message exceeded Google's message size limits. Please visit https://support.google.com/mail/?p=MaxSizeError to view our size guidelines. l192-20020a6391c9000000b005347ef6ec11si198010pge.760 - gsmtp at 2023-05-31 11:48:50

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    malimings@gmail.com

  • User Avatar
    0
    cunyong.yu@vskysoft.com created

    Still failed

  • User Avatar
    0
    cunyong.yu@vskysoft.com created

    Successfully sent

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    Thanks

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    Source code also is broken.

  • User Avatar
    0
    cunyong.yu@vskysoft.com created

    Source code also is broken.

    I have resend a decrypted project, and there should be no damaged files.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    Configure<HubOptions>(options =>
    {
        options.DisableImplicitFromServicesParameters = true;
    });
    

    https://github.com/dotnet/aspnetcore/issues/38842#issuecomment-1342540950

  • User Avatar
    0
    cunyong.yu@vskysoft.com created

    hi

    Configure<HubOptions>(options => 
    { 
        options.DisableImplicitFromServicesParameters = true; 
    }); 
    

    https://github.com/dotnet/aspnetcore/issues/38842#issuecomment-1342540950

    The error has been resolved, thank you.

Made with ❤️ on ABP v9.1.0-preview. Updated on November 01, 2024, 05:35