MudBlazor.Extensions
MudBlazor.Extensions copied to clipboard
[Bug]: MudExDialogService.ShowFileDisplayDialog error/unexpected behaviour on specific data types
Contact Details
No response
What happened?
Previously, ShowFileDisplayDialog worked fine for any file type.
With updating to MudBlazor 7.0.0 combined with Extensions 2.0.0 i'm getting errors on Excel- and zip- Files.
Zip error is:
Microsoft.AspNetCore.Components.Server.Circuits.RemoteRenderer[100] Unhandled exception rendering component: Self referencing loop detected with type 'MudBlazor.Extensions.Core.MudExArchiveStructure'. Path '[4].Value[0].Path'. Newtonsoft.Json.JsonSerializationException: Self referencing loop detected with type 'MudBlazor.Extensions.Core.MudExArchiveStructure'. Path '[4].Value[0].Path'. at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.CheckForCircularReference(JsonWriter writer, Object value, JsonProperty property, JsonContract contract, JsonContainerContract containerContract, JsonProperty containerProperty)
Excel error is:
Microsoft.JSInterop.JSException: An exception occurred executing JS interop: JSON serialization is attempting to deserialize an unexpected byte array.. See InnerException for more details. ---> System.Text.Json.JsonException: JSON serialization is attempting to deserialize an unexpected byte array. at Microsoft.JSInterop.Infrastructure.ByteArrayJsonConverter.Read(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options)
Opening a jpg results in:
Swiching to Native Control and back to MudExImageViewer shows the image again without any errors.
Executing Code:
string mimetype = String.IsNullOrEmpty(uploadedFile.uploaded_file_content_type) ? Utilities.Utilities.GetMimeType(uploadedFile.uploaded_file_orig_file_name) : uploadedFile.uploaded_file_content_type;
var parameters = new DialogParameters {
{ nameof(MudExFileDisplay.StreamUrlHandling), StreamUrlHandling.BlobUrl }
};
using (Stream stream = GetFileStream(uploadedFile))
{
var reference = await DialogService.ShowFileDisplayDialog(stream, uploadedFile.uploaded_file_orig_file_name, mimetype, HandleContentError, ex => ex.JsRuntime = JS, parameters);
await reference.Result;
}
Function GetFileStream:
private Stream GetFileStream(UploadedFileModel model)
{
return File.OpenRead(Path.Combine(AppServerSettings.appServerSettings.functionSettings.UploadBaseFolder, model.uploaded_file_relative_filepath));
}
Expected Behavior
Opening all file types like before.
Screenshots
No response
Reproduction link
No response
What application type are you referring to?
ServerRendered
Custom Application Type
No response
MudBlazor.Extension Version
2.0.0
MudBlazor Version
7.0.0
What .net Version are you using?
.Net7
What browser are you using?
Chrome
Sample Solution
No response
Pull Request
No response
Code of Conduct
- [X] I agree to follow this project's Code of Conduct