I have a strange problem with RadzenUpload
where it only works for the first time.
Here are the relevant code bits:
<RadzenUpload Url="@($"upload/{_uploadId}")"
Visible="@(!_uploading)"
Progress="OnProgress"
Error="OnErrorAsync"
Complete="OnComplete"
Name="file"
Accept=".inp,.inp.gz,.inp.bz2,.inp.xz,.tar,.tar.gz,.tgz,.tar.bz2,.tbz2,.tar.xz,.txz,.zip,.rar,.7z" />
private void OnProgress(UploadProgressArgs args) {
_uploading = true;
_progress = args.Progress;
args.Cancel = _cancel;
_cancel = false;
}
private async Task OnErrorAsync(UploadErrorEventArgs args) {
try {
await _uploadService.ClearUploadAsync(_uploadId);
} catch(Exception e) {
_logger.LogWarning(e, "Failed to clear upload: {msg}", e.Message);
}
_uploading = false;
_cancel = false;
_prep.FileUploaded = false;
await _dialogService.Alert(string.IsNullOrWhiteSpace(args.Message) ? "The file failed to upload" : args.Message,
"Upload failed",
new() {
AutoFocusFirstElement = true,
CloseDialogOnEsc = true,
CloseDialogOnOverlayClick = true,
Draggable = true,
OkButtonText = "OK",
Resizable = true,
ShowClose = true,
ShowTitle = true
});
}
private void OnComplete(UploadCompleteEventArgs args) {
_uploading = false;
_cancel = false;
_prep.FileUploaded = true;
}
This works for the first time. When I then try to upload a second file, I get the following:
Uncaught Error Error: System.ArgumentException: There is no tracked object with id '4'. Perhaps the DotNetObjectReference instance was already disposed. (Parameter 'dotNetObjectId')
at endInvokeDotNetFromJS (localhost꞉5030/_framework/blazor.web.js:1:3502)
at _invokeClientMethod (localhost꞉5030/_framework/blazor.web.js:1:62841)
at _processIncomingData (localhost꞉5030/_framework/blazor.web.js:1:60316)
at connection.onreceive (localhost꞉5030/_framework/blazor.web.js:1:53957)
at i.onmessage (localhost꞉5030/_framework/blazor.web.js:1:82102)
Do I somehow have to reset the component before I can do another upload?