Open Closed

FileEdit and FilePicker Throw Exceptions with .Net 7 and ABP 7.0.0-rc.2 #4127


User avatar
1
DWaterfield created

Hang then Exception thrown with Blazor (Blazorise) FileEdit and FilePicker controls

  • ABP Framework version: 7.0.0-rc.2
  • UI type: Blazor-Server
  • DB provider: EF Core
  • Tiered (MVC) or Identity Server Separated (Angular): yes
  • Exception message and stack trace: 2022-11-28 10:49:33.059 +00:00 [ERR] Unhandled exception in circuit '95WDlnCZhdm60L5gxJEcLEXfawZQRcSbNWf878BV7qg'. System.TimeoutException: Did not receive any data in the allotted time. at System.IO.Pipelines.Pipe.GetReadResult(ReadResult& result) at System.IO.Pipelines.Pipe.GetReadAsyncResult() at System.IO.Pipelines.PipeReaderStream.ReadAsyncInternal(Memory`1 buffer, CancellationToken cancellationToken)
  • Steps to reproduce the issue:
  1. abp new BookStoreV7 -ui blazor-server --preview
  2. build the Solution and run the DbMigrator project
  3. Switch the Visual Studio from IISExpress to e.g. BookStoreV7.Blazor via the dropdown (next to 'Debug', 'AnyCpu' and 'BookStoreV7.Blazor' controls
  4. Add in a FileEdit control to Index.razor (FilePicker is also affected) e.g.
<Field>
    <FileEdit Changed="OnFileUpload" />
</Field>
  1. Add a method in the code behind e.g.
using Blazorise;
using System.IO;
using System.Threading.Tasks;
using System;

namespace BookStoreV7.Blazor.Pages;

public partial class Index
{
    async Task OnFileUpload(FileChangedEventArgs e)
    {
        try
        {
            if (e.Files.Length > 0)
            {
                var file = e.Files[0];

                using var memoryStream = new MemoryStream();
                // Next statement hangs, then throws exception
                await file.OpenReadStream(int.MaxValue).CopyToAsync(memoryStream);
            }
        }
        catch (Exception ex)
        {
            //Console.WriteLine(ex.Message);
        }
        finally
        {
            this.StateHasChanged();
        }
    }
}
  1. Set the startup project to the web one e.g. BookStoreV7.Blazor and run it
  2. Click on the "Choose file" control, select a file and click ok
  3. The app will hang then throw an exception on the statement await file.OpenReadStream(int.MaxValue).CopyToAsync(memoryStream);

I can confirm that the FileEdit (and FilePicker) control works in a .Net 7, non ABP Blazor Server app i.e. adding Blazorise to it as detailed here: Blazorise Quick Start Guid It seems to be related to the underlying FileEntry.OpenReadStream() when used in an ABP 7.0.0-rc.2 project.

Images Stack Trace

at System.IO.Pipelines.Pipe.GetReadResult(ReadResult& result) at System.IO.Pipelines.Pipe.GetReadAsyncResult() at System.Runtime.CompilerServices.ConfiguredValueTaskAwaitable`1.ConfiguredValueTaskAwaiter.GetResult() at System.IO.Pipelines.PipeReaderStream.&lt;ReadAsyncInternal>d__30.MoveNext() at System.Threading.Tasks.ValueTask`1.get_Result() at System.Runtime.CompilerServices.ValueTaskAwaiter`1.GetResult() at Microsoft.AspNetCore.Components.Server.Circuits.RemoteJSDataStream.&lt;ReadAsync>d__36.MoveNext() at System.Threading.Tasks.ValueTask`1.get_Result() at System.Runtime.CompilerServices.ValueTaskAwaiter`1.GetResult() at Blazorise.RemoteFileEntryStream.&lt;CopyFileDataIntoBuffer>d__13.MoveNext() at System.Threading.Tasks.ValueTask`1.get_Result() at System.Runtime.CompilerServices.ValueTaskAwaiter`1.GetResult() at Blazorise.RemoteFileEntryStream.&lt;ReadAsync>d__15.MoveNext() at System.IO.Stream.<&lt;CopyToAsync&gt;g__Core|27_0>d.MoveNext() at BookStoreV7.Blazor.Pages.Index.&lt;OnFileUpload>d__0.MoveNext() in C:\Users\Moor Deybe\source\My Stuff\ABPStuff\ABPV7-BookStore\src\BookStoreV7.Blazor\Pages\Index.razor.cs:line 20


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

    hi

    this seems asp net core issue

    https://github.com/dotnet/aspnetcore/issues/38842

  • User Avatar
    0
    DWaterfield created

    Hi,

    Thanks for that link, I have subscribed to it.

    Obviously, there is more to this than is apparent as a plain .Net 7, Blazor server, Blazorise app works but a default ABP 7, .Net 7, Blazor Server app is somehow different and an issue involving the ASP.Net Core / SignalR connection and streams is exposed in that scenario.

    If you leave this thread open then we will post here once MS has resolved the issue that they have found, and we can verify that FileEdit and FilePicker once again work with ABP 7.0 / .Net7, so that others can see.

    Thanks

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    OK, No problem.

Made with ❤️ on ABP v9.1.0-preview. Updated on December 12, 2024, 07:15