I'm building an ASP.NET core application with ef core. When I try to show a Popup that doesn't have a timeout with this command:
await _jsRuntime.InvokeAsync<Task>("showVersionUpdate", version, System.Threading.CancellationToken.None);
I get the following error:
System.NotSupportedException: 'Serialization and deserialization of 'System.IntPtr' instances is not supported. Path: $.WaitHandle.Handle. NotSupportedException: Serialization and deserialization of 'System.IntPtr' instances is not supported. '
Any help is appreciated!
PS: I've tried removing the cancellation token completely but it still timesout after a couple of seconds. The showVersionUpdate is a sweetalert2 popup
I'm building an ASP.NET core application with ef core. When I try to show a Popup that doesn't have a timeout with this command:
await _jsRuntime.InvokeAsync<Task>("showVersionUpdate", version, System.Threading.CancellationToken.None);
I get the following error:
System.NotSupportedException: 'Serialization and deserialization of 'System.IntPtr' instances is not supported. Path: $.WaitHandle.Handle. NotSupportedException: Serialization and deserialization of 'System.IntPtr' instances is not supported. '
Any help is appreciated!
PS: I've tried removing the cancellation token completely but it still timesout after a couple of seconds. The showVersionUpdate is a sweetalert2 popup
Share Improve this question edited Feb 6 at 11:37 Panagiotis Kanavos 131k16 gold badges203 silver badges265 bronze badges asked Feb 6 at 10:00 KentKent 271 silver badge6 bronze badges 6 | Show 1 more comment1 Answer
Reset to default 1Try using
await _jsRuntime.InvokeVoidAsync("showVersionUpdate", version);
All cancellable Invoke...Async expect the cancellation token as the second parameter followed by a params object?[]? args
list of parameters. The question's code is trying to send the CancellationToken to the browser.
Javascript methods that don't return anything should be called using the InvokeVoidAsync extension method, not an arbitrary result type.
it still timesout after a couple of seconds
what times out and what's the error message? The Javascript call? The EF call? The server-side push to the client? – Panagiotis Kanavos Commented Feb 6 at 10:55InvokeAsync
, the code is trying to pass it to JavaScript. Have you tried usingawait _jsRuntime.InvokeVoidAsync("showVersionUpdate", CancellationToken.None, version);
? – Panagiotis Kanavos Commented Feb 6 at 11:34I've tried removing the cancellation token completely but it still timesout after a couple of seconds.
you mean the popup times out after a couple of seconds? What doesshowVersionUpdate
contain? Why would a JS method take seconds to complete? Unless it blocks waiting for the user to confirm? – Panagiotis Kanavos Commented Feb 6 at 11:37