abp icon indicating copy to clipboard operation
abp copied to clipboard

injecting IJSRuntime by constructor result in different/not useable instance

Open puschie286 opened this issue 3 years ago • 0 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

Description

When using constructor DI for blazor components with IJSRuntime - you will get a different / broken instance. This instance will always throw an exception on any InvokeAsync call

if you use property DI it works as inteded

Reproduction Steps

  1. create blazor component with IJSRuntime injected by constructor
  2. call InvokeAsync inside OnAfterRenderAsync

Expected behavior

No response

Actual behavior

exception thrown

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)

Regression?

No response

Known Workarounds

dont use constructor DI for blazor components

Version

6.0.1

User Interface

Blazor Server

Database Provider

EF Core (Default)

Tiered or separate authentication server

None (Default)

Operation System

Windows (Default)

Other information

No response

puschie286 avatar Dec 07 '22 14:12 puschie286