https://github.com/lostbeard/blazorijsinprocessobjectreferencedisposebugtest
https://github.com/lostbeard/blazorijsinprocessobjectreferencedisposebugtest
Last synced: 7 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/lostbeard/blazorijsinprocessobjectreferencedisposebugtest
- Owner: LostBeard
- License: mit
- Created: 2023-05-18T21:55:02.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-05-19T00:41:32.000Z (over 2 years ago)
- Last Synced: 2025-03-10T14:18:29.114Z (7 months ago)
- Language: C#
- Size: 13.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# 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.4The 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"```cs
[JSImport("DotNet.jsCallDispatcher.disposeJSObjectReferenceById", "blazor-internal")]
private static partial void DisposeJSObjectReferenceById([JSMarshalAs] long id);
```If switched to the below JSImport it works.
```cs
[JSImport("globalThis.DotNet.jsCallDispatcher.disposeJSObjectReferenceById")]
private static partial void DisposeJSObjectReferenceById([JSMarshalAs] long id);
```## Note
Template used is "Blazor WebAssembly App Empty". Only the "Program.cs" has been modified.