Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Blazor File Upload issue with Net 7 and MS DI Package #547

Closed
oruchreis opened this issue Nov 23, 2022 · 4 comments
Closed

Blazor File Upload issue with Net 7 and MS DI Package #547

oruchreis opened this issue Nov 23, 2022 · 4 comments
Assignees
Labels
bug Something isn't working
Milestone

Comments

@oruchreis
Copy link

oruchreis commented Nov 23, 2022

Hi,
I don't know it is relevant or not with #544 but If we use DryIoc.Microsoft.DependencyInjection v6.*.* package with Net 7, the file upload doesn't work. I'm integrating DryIoc like this:
Program.cs:

var builder = WebApplication.CreateBuilder(args);
builder.Host.UseServiceProviderFactory(new DryIocServiceProviderFactory());

and simple upload page:
Upload.razor:

<InputFile OnChange="Upload" />
@_newDocumentUploadProgress %
@code {
    private double _newDocumentUploadProgress;
    private async Task Upload(InputFileChangeEventArgs args)
    {
        var file = args.File;
        await using var uploadStream = file.OpenReadStream(maxAllowedSize: 10 * 1024 * 1024);
        var bytesRead = 0;
        var totalRead = 0;
        var buffer = new byte[10];
        await using var memStream = new MemoryStream();

        while ((bytesRead = await uploadStream.ReadAsync(buffer)) != 0)
        {
            totalRead += bytesRead;

            await memStream.WriteAsync(buffer, 0, bytesRead);

            _newDocumentUploadProgress = (totalRead / uploadStream.Length) * 100;
            StateHasChanged();
        }

        memStream.Position = 0;
    }
}

Actually all js streaming is not working with DryIoc.Microsoft.DependencyInjection v6.* with Net 7. If I comment out DryIocServiceProviderFactory line, it is working.

@dadhi
Copy link
Owner

dadhi commented Nov 24, 2022

@oruchreis Huh, more incencitive to release #544 faster. Thanks.

@MaxwellDAssistek
Copy link

I can reproduce this issue as well and it does not happen without DryIoc. Here is the actual exception that is happening:

2023-04-14 09:36:46.604 -04:00 [VRB] InvocationId null: Sending result of type 'System.Void'.
2023-04-14 09:36:46.605 -04:00 [DBG] Parameters to hub method 'ReceiveJSDataChunk' are incorrect.
System.IO.InvalidDataException: Invocation provides 4 argument(s) but target expects 3.
   at Microsoft.AspNetCore.SignalR.Protocol.MessagePackHubProtocolWorker.BindArguments(MessagePackReader& reader, IReadOnlyList`1 parameterTypes)
   at Microsoft.AspNetCore.SignalR.Protocol.MessagePackHubProtocolWorker.CreateInvocationMessage(MessagePackReader& reader, IInvocationBinder binder, Int32 itemCount)
2023-04-14 09:36:46.634 -04:00 [DBG] Parameters to hub method 'ReceiveJSDataChunk' are incorrect.
System.IO.InvalidDataException: Invocation provides 4 argument(s) but target expects 3.
   at Microsoft.AspNetCore.SignalR.Protocol.MessagePackHubProtocolWorker.BindArguments(MessagePackReader& reader, IReadOnlyList`1 parameterTypes)
   at Microsoft.AspNetCore.SignalR.Protocol.MessagePackHubProtocolWorker.CreateInvocationMessage(MessagePackReader& reader, IInvocationBinder binder, Int32 itemCount)
2023-04-14 09:36:52.641 -04:00 [VRB] Message received. Type: "Binary", size: 3, EndOfMessage: true.

dadhi added a commit that referenced this issue Apr 17, 2023
@dadhi dadhi self-assigned this Apr 17, 2023
@dadhi dadhi added the bug Something isn't working label Apr 17, 2023
@dadhi dadhi added this to the v5.4.0 milestone Apr 17, 2023
@dadhi
Copy link
Owner

dadhi commented Apr 17, 2023

@oruchreis @MaxwellDAssistek I have checked that it is working with .NET 7 and DryIoc.MS.DI v6.2.0-preview-01

@Maxwell175
Copy link

@dadhi Can confirm that it works for me as well.

@dadhi dadhi closed this as completed Apr 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants