Skip to content

There is no tracked object with id '5'. Perhaps the DotNetObjectReference instance was already disposed #120

Open
@Dupie123

Description

@Dupie123

Please see the following issue

Uncaught (in promise) Error: System.ArgumentException: There is no tracked object with id '5'. Perhaps the DotNetObjectReference instance was already disposed. (Parameter 'dotNetObjectId')
at Microsoft.JSInterop.JSRuntime.GetObjectReference(Int64 dotNetObjectId)
at Microsoft.JSInterop.Infrastructure.DotNetDispatcher.BeginInvokeDotNet(JSRuntime jsRuntime, DotNetInvocationInfo invocationInfo, String argsJson)
at Object.endInvokeDotNetFromJS (blazor.webassembly.js:1:3531)
at Object.Rt [as endInvokeDotNetFromJS] (blazor.webassembly.js:1:60566)
at Object.St [as invokeJSFromDotNet] (blazor.webassembly.js:1:60049)
at _mono_wasm_invoke_js_blazor (dotnet.6.0.10.ab6o20rtby.js:1:195300)
at 00971d2a:0x1a492
at 00971d2a:0xce60
at 00971d2a:0xbd73
at 00971d2a:0xabebf
at 00971d2a:0x6fc80
at 00971d2a:0x702ed

When using IClickBoundariesHandler and calling the following

await _clickHandler.RegisterClickBoundariesAsync(_clickDiv,
async (args) => await PageClick(args, false),
async (args) => await PageClick(args, true));
_clickSubscribed = true;

I then have the following code on IAsyncDisposable.DisposeAsync()

if (_clickSubscribed)
await _clickHandler.RemoveClickBoundariesAsync(_clickDiv);
await _clickHandler.DisposeAsync();

But when the page navigates away the error above is returned. Going back to the first page now doubles the error to 2 elements registered by the click event causing a memory leak

Uncaught (in promise) Error: System.ArgumentException: There is no tracked object with id '10'. Perhaps the DotNetObjectReference instance was already disposed. (Parameter 'dotNetObjectId')
at Microsoft.JSInterop.JSRuntime.GetObjectReference(Int64 dotNetObjectId)
at Microsoft.JSInterop.Infrastructure.DotNetDispatcher.BeginInvokeDotNet(JSRuntime jsRuntime, DotNetInvocationInfo invocationInfo, String argsJson)
at Object.endInvokeDotNetFromJS (blazor.webassembly.js:1:3531)
at Object.Rt [as endInvokeDotNetFromJS] (blazor.webassembly.js:1:60566)
at Object.St [as invokeJSFromDotNet] (blazor.webassembly.js:1:60049)
at _mono_wasm_invoke_js_blazor (dotnet.6.0.10.ab6o20rtby.js:1:195300)
at 00971d2a:0x1a492
at 00971d2a:0xce60
at 00971d2a:0xbd73
at 00971d2a:0xabebf
at 00971d2a:0x6fc80
at 00971d2a:0x702ed

Can you please assit me in solving the issue

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions