Skip to content

I get an exception from deep inside your rendering and I cannot trap it, can you help? #546

@SteveStrong

Description

@SteveStrong
public void Dispose()
{
    Node.Changed -= OnNodeChanged;
    Node.VisibilityChanged -= OnVisibilityChanged;

    if (_element.Id != null && !Node.ControlledSize)
    {
        try
        {
            //_ = JsRuntime.UnobserveResizes(_element, _reference!);
           // _ = JsRuntime.UnobserveResizes(_element);
        }
        catch
        {
        }
    }

   // _reference?.Dispose();
}

fail: Microsoft.AspNetCore.Server.Kestrel[13]
Connection id "0HNEOPT784CMV", Request id "0HNEOPT784CMV:00000002": An unhandled exception was thrown by the application.
System.InvalidOperationException: JavaScript interop calls cannot be issued at this time. This is because the component is being statically rendered. When prerendering is enabled, JavaScript interop calls can only be performed during the OnAfterRenderAsync lifecycle method.
at Microsoft.AspNetCore.Components.Server.Circuits.RemoteJSRuntime.BeginInvokeJS(Int64 asyncHandle, String identifier, String argsJson, JSCallResultType resultType, Int64 targetInstanceId)
at Microsoft.JSInterop.JSRuntime.InvokeAsync[TValue](Int64 targetInstanceId, String identifier, CancellationToken cancellationToken, Object[] args)
at Microsoft.JSInterop.JSRuntime.InvokeAsync[TValue](Int64 targetInstanceId, String identifier, Object[] args)
at Microsoft.JSInterop.JSRuntimeExtensions.InvokeVoidAsync(IJSRuntime jsRuntime, String identifier, Object[] args)
at Blazor.Diagrams.Extensions.JSRuntimeExtensions.UnobserveResizes(IJSRuntime jsRuntime, ElementReference element)
at Blazor.Diagrams.Components.DiagramCanvas.DisposeAsync()
at Microsoft.AspNetCore.Components.RenderTree.Renderer.<>c__DisplayClass93_0.<g__HandleAsyncExceptions|0>d.MoveNext()
--- End of stack trace from previous location ---
at Microsoft.AspNetCore.Components.HtmlRendering.Infrastructure.StaticHtmlRenderer.HandleException(Exception exception)
at Microsoft.AspNetCore.Components.RenderTree.Renderer.<>c__DisplayClass93_0.g__NotifyExceptions|1(List1 exceptions) at Microsoft.AspNetCore.Components.RenderTree.Renderer.<>c__DisplayClass93_0.<<Dispose>g__HandleAsyncExceptions|0>d.MoveNext() --- End of stack trace from previous location --- at Microsoft.AspNetCore.Components.RenderTree.Renderer.DisposeAsync() at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope.<DisposeAsync>g__Await|26_0(Int32 i, ValueTask vt, List1 toDispose)
at Microsoft.AspNetCore.Http.Features.RequestServicesFeature.g__Awaited|9_0(RequestServicesFeature servicesFeature, ValueTask vt)
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.g__ProcessEvents|242_0(HttpProtocol protocol, Stack`1 events)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions