RadzenUpload remove method causes NullReferenceException when using custom properties in FileInfo #1748

Closed
opened 2026-01-29 17:58:00 +00:00 by claunia · 3 comments
Owner

Originally created by @pedro-cons on GitHub (May 4, 2025).

There is a bug in the RadzenUpload component when using properties in FileInfo.

When the OnRemove method is triggered, the Change event only propagates a List with Name and Size. If you rely on other properties for validation or processing, this can lead to a NullReferenceException.

protected async System.Threading.Tasks.Task OnRemove(PreviewFileInfo file, bool fireChangeEvent = true)
{
    files.Remove(file);
    await JSRuntime.InvokeVoidAsync("Radzen.removeFileFromUpload", fileUpload, file.Name);
    if (fireChangeEvent) await Change.InvokeAsync(new UploadChangeEventArgs() { Files = files.Select(f => new FileInfo() { Name = f.Name, Size = f.Size }).ToList() });
}

I’m available and happy to submit a PR to update this behavior by including the remaining properties in the projection.

Files = files.Select(f => new FileInfo()
{
    Name = f.Name,
    Size = f.Size
    // Other properties are ignored here
}).ToList()

Let me know if that would be welcome!

Thanks in advance!

Originally created by @pedro-cons on GitHub (May 4, 2025). There is a bug in the RadzenUpload component when using properties in FileInfo. When the OnRemove method is triggered, the Change event only propagates a List<FileInfo> with Name and Size. If you rely on other properties for validation or processing, this can lead to a NullReferenceException. ``` protected async System.Threading.Tasks.Task OnRemove(PreviewFileInfo file, bool fireChangeEvent = true) { files.Remove(file); await JSRuntime.InvokeVoidAsync("Radzen.removeFileFromUpload", fileUpload, file.Name); if (fireChangeEvent) await Change.InvokeAsync(new UploadChangeEventArgs() { Files = files.Select(f => new FileInfo() { Name = f.Name, Size = f.Size }).ToList() }); } ``` I’m available and happy to submit a PR to update this behavior by including the remaining properties in the projection. ``` Files = files.Select(f => new FileInfo() { Name = f.Name, Size = f.Size // Other properties are ignored here }).ToList() ``` Let me know if that would be welcome! Thanks in advance!
Author
Owner

@enchev commented on GitHub (May 5, 2025):

Not sure what a the other properties. Please provide an example where we can replicate the problem.

@enchev commented on GitHub (May 5, 2025): Not sure what a the other properties. Please provide an example where we can replicate the problem.
Author
Owner

@enchev commented on GitHub (May 7, 2025):

I'm closing this since no additional information or example is provided.

@enchev commented on GitHub (May 7, 2025): I'm closing this since no additional information or example is provided.
Author
Owner

@pedro-cons commented on GitHub (May 12, 2025):

I've just submitted a PR to address this issue: #2151. Let me know if any changes are needed!

@pedro-cons commented on GitHub (May 12, 2025): I've just submitted a PR to address this issue: [#2151](https://github.com/radzenhq/radzen-blazor/pull/2151). Let me know if any changes are needed!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/radzen-blazor#1748