We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

SfTab crashes app with Arg_InvalidCastException

Hi,

We have users reporting the following critical error which crashes our app (Blazor WASM with AOT) periodically.

It appears to be coming from the SfTab component, but we are unable to figure out what the problem might be.


Please advise, thanks John


blazor.webassembly.js:1 crit: Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer[100]

Unhandled exception rendering component: Arg_InvalidCastException

System.InvalidCastException: Arg_InvalidCastException

at System.Object.CssClassGetter(Object)

at System.Text.Json.Serialization.JsonConverter`1[[System.Collections.Generic.List`1[[Syncfusion.Blazor.Navigations.TabItem, Syncfusion.Blazor.Navigations, Version = 20.3.0.57, Culture = neutral, PublicKeyToken = null]], System.Private.CoreLib, Version = 7.0.0.0, Culture = neutral, PublicKeyToken = 7cec85d7bea7798e]].WriteCore(Utf8JsonWriter, List`1 & , JsonSerializerOptions, WriteStack & )

at System.Text.Json.JsonSerializer.WriteString[List`1](List`1 & , JsonTypeInfo`1)

at Syncfusion.Blazor.Navigations.SfTab.OnParametersSetAsync()

at System.Object.CssClassGetter(Object)

at System.Text.Json.Serialization.JsonConverter`1[[System.Collections.Generic.List`1[[Syncfusion.Blazor.Navigations.TabItem, Syncfusion.Blazor.Navigations, Version = 20.3.0.57, Culture = neutral, PublicKeyToken = null]], System.Private.CoreLib, Version = 7.0.0.0, Culture = neutral, PublicKeyToken = 7cec85d7bea7798e]].WriteCore(Utf8JsonWriter, List`1 & , JsonSerializerOptions, WriteStack & )

at System.Text.Json.JsonSerializer.WriteString[List`1](List`1 & , JsonTypeInfo`1)

at Microsoft.AspNetCore.Components.ComponentBase.CallStateHasChangedOnAsyncCompletion(Task task)



5 Replies

RM Ruksar Moosa Sait Syncfusion Team November 24, 2022 02:48 PM UTC

Hi John,


We looked into the issue you reported, but we still require more details to fully analyze it and provide an appropriate solution.

Please share the details below.

 

  • Issue replicating code snippets or
  • Issue reproducing sample.


MK Michael Kanios December 3, 2022 11:21 AM UTC

Hi Ruksar,


I'm getting the same error. I believe it has to do with AOT as I'm getting this error only on release with AOT...

To reproduce the error:

  1. Add an SfTab in a component which has a link from main menu
  2. After opening the page that has the tab, hit the link to the same page





RM Ruksar Moosa Sait Syncfusion Team December 7, 2022 04:15 PM UTC

Michael, We have prepared a sample with AOT and checked the reported issue in the hosting(release) but unfortunately we could not reproduce the issue at our end. We require the below details to proceed further.


  • Video demo replicating the issue.
  • Entire issue reproducing tab related code snippets.(Like how Tab rendered in a component and how that linked from the main menu)


MK Michael Kanios December 8, 2022 03:37 PM UTC

Hi Ruksar,


After careful investigation, it seems the issue is not related to Syncfusion as I'm getting this error for different components in the app. It seems the same with the one reported here:

System.InvalidCastException: Arg_InvalidCastException after upgrading blazor webassembly from .net 6 to .net 7 · Issue #78864 · dotnet/runtime · GitHub


I'm getting the same for SfGrid as  well.

I managed to get this only at  release with AOT, and it happens some times after you immediately click on another menu item that redirects to a different component or even the same component.


If I manage to get more information, I'll share it here, or the dotnet Github repo if it's more relevant.

Below you can find the same error with SfGrid if that matters.



Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer[100]

      Unhandled exception rendering component: Arg_InvalidCastException

System.InvalidCastException: Arg_InvalidCastException

   at System.Object.TableWidthGetter(Object )

   at System.Text.Json.Serialization.JsonConverter`1[[System.Collections.Generic.IDictionary`2[[System.String, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.Object, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]], System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].WriteCore(Utf8JsonWriter , IDictionary`2& , JsonSerializerOptions , WriteStack& )

   at System.Text.Json.JsonSerializer.WriteString[IDictionary`2](IDictionary`2& , JsonTypeInfo`1 )

   at Syncfusion.Blazor.Grids.SfGrid`1.



RV Ravikumar Venkatesan Syncfusion Team December 13, 2022 02:20 PM UTC

We were unable to replicate the issue at our end. We have prepared a NET7 AOT enabled Blazor WebAssembly application which you can download from the below link.


Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/WasmNet7600100399


We have provided compatibility support for NET7 from the Volume 3 2022 release ( version: 20.3.47) and are able to render controls without any issues. If the issue persists, share the below details to validate further.


  • Version of Syncfusion packages used in the application
  • List of Syncfusion controls used.
  • List of Syncfusion NuGet packages used.
  • Image/ Video reference of the exact issue occurring.
  • Replicate the issue in the shared sample.

Loader.
Live Chat Icon For mobile
Up arrow icon