Skip to content

LostBeard/BlazorIJSInProcessObjectReferenceDisposeBugTest

Repository files navigation

Blazor IJSInProcessObjectReference Dispose Bug Test and Fix

Demonstrates aspnetcore bug #48280 "Exception calling Dispose on IJSInProcessObjectReference instance in Blazor WebAssembly" and a fix from submitted pull request #48287.

Describe the bug

Calling Dispose on an instance of IJSInProcessObjectReference throws an exception. Only affects Blazor WebAssembly.

Affected versions of DotNet

8.0.0-preview.3.23177.8
8.0.0-preview.4.23260.4

The bug seems to arise from pull #46693. They switched from using IJSUnmarshalledRuntime to JSImport for calling "DotNet.jsCallDispatcher.disposeJSObjectReferenceById" but it fails. The JSImport attribute gives an incorrect location for the function to call.

From repo
dotnet/aspnetcore
"aspnetcore/src/JSInterop/Microsoft.JSInterop/src/Implementation/JSInProcessObjectReference.cs"

    [JSImport("DotNet.jsCallDispatcher.disposeJSObjectReferenceById", "blazor-internal")]
    private static partial void DisposeJSObjectReferenceById([JSMarshalAs<JSType.Number>] long id);

If switched to the below JSImport it works.

    [JSImport("globalThis.DotNet.jsCallDispatcher.disposeJSObjectReferenceById")]
    private static partial void DisposeJSObjectReferenceById([JSMarshalAs<JSType.Number>] long id);

Note

Template used is "Blazor WebAssembly App Empty". Only the "Program.cs" has been modified.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published