Share via

Unhandled exception rendering component: NullabilityInfoContext_NotSupported

ta 40 Reputation points
2026-02-27T15:50:10.0333333+00:00

crit: Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer[100] Unhandled exception rendering component: NullabilityInfoContext_NotSupported System.InvalidOperationException: NullabilityInfoContext_NotSupported at System.Reflection.NullabilityInfoContext.EnsureIsSupported() at System.Reflection.NullabilityInfoContext.Create(PropertyInfo ) at System.Text.Json.Serialization.Metadata.DefaultJsonTypeInfoResolver.DeterminePropertyNullability(JsonPropertyInfo , MemberInfo , NullabilityInfoContext ) at System.Text.Json.Serialization.Metadata.DefaultJsonTypeInfoResolver.PopulatePropertyInfo(JsonPropertyInfo , MemberInfo , JsonConverter , Nullable1 , NullabilityInfoContext , Boolean , Boolean ) at System.Text.Json.Serialization.Metadata.DefaultJsonTypeInfoResolver.CreatePropertyInfo(JsonTypeInfo , Type , MemberInfo , NullabilityInfoContext , JsonSerializerOptions , Boolean , Boolean ) at System.Text.Json.Serialization.Metadata.DefaultJsonTypeInfoResolver.AddMember(JsonTypeInfo , Type , MemberInfo , NullabilityInfoContext , Boolean , Boolean , PropertyHierarchyResolutionState& ) at System.Text.Json.Serialization.Metadata.DefaultJsonTypeInfoResolver.AddMembersDeclaredBySuperType(JsonTypeInfo , Type , NullabilityInfoContext , Boolean , PropertyHierarchyResolutionState& ) at System.Text.Json.Serialization.Metadata.DefaultJsonTypeInfoResolver.PopulateProperties(JsonTypeInfo , NullabilityInfoContext ) at System.Text.Json.Serialization.Metadata.DefaultJsonTypeInfoResolver.CreateTypeInfoCore(Type , JsonConverter , JsonSerializerOptions ) at System.Text.Json.Serialization.Metadata.DefaultJsonTypeInfoResolver.CreateJsonTypeInfo(Type , JsonSerializerOptions ) at System.Text.Json.Serialization.Metadata.DefaultJsonTypeInfoResolver.GetTypeInfo(Type , JsonSerializerOptions ) at System.Text.Json.JsonSerializerOptions.GetTypeInfoNoCaching(Type ) at System.Text.Json.JsonSerializerOptions.CachingContext.CreateCacheEntry(Type type, CachingContext context) --- End of stack trace from previous location --- at System.Text.Json.JsonSerializerOptions.CachingContext.CacheEntry.GetResult() at System.Text.Json.JsonSerializerOptions.CachingContext.GetOrAddTypeInfo(Type , Boolean ) at System.Text.Json.JsonSerializerOptions.GetTypeInfoInternal(Type , Boolean , Nullable1 , Boolean , Boolean ) at System.Text.Json.WriteStackFrame.InitializePolymorphicReEntry(Type , JsonSerializerOptions ) at System.Text.Json.Serialization.JsonConverter.ResolvePolymorphicConverter(Object , JsonTypeInfo , JsonSerializerOptions , WriteStack& ) at System.Text.Json.Serialization.JsonConverter1[[System.Object, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].TryWrite(Utf8JsonWriter , Object& , JsonSerializerOptions , WriteStack& ) at System.Text.Json.Serialization.Converters.ArrayConverter2[[System.Object[], System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.Object, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].OnWriteResume(Utf8JsonWriter , Object[] , JsonSerializerOptions , WriteStack& ) at System.Text.Json.Serialization.JsonCollectionConverter2[[System.Object[], System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.Object, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].OnTryWrite(Utf8JsonWriter , Object[] , JsonSerializerOptions , WriteStack& ) at System.Text.Json.Serialization.JsonConverter1[[System.Object[], System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].TryWrite(Utf8JsonWriter , Object[]& , JsonSerializerOptions , WriteStack& ) at System.Text.Json.Serialization.JsonConverter1[[System.Object[], System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].WriteCore(Utf8JsonWriter , Object[]& , JsonSerializerOptions , WriteStack& ) at System.Text.Json.Serialization.Metadata.JsonTypeInfo1[[System.Object[], System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].Serialize(Utf8JsonWriter , Object[]& , Object ) at System.Text.Json.JsonSerializer.WriteStringObject[] at System.Text.Json.JsonSerializer.SerializeObject[] at Microsoft.JSInterop.JSRuntime.InvokeAsyncIJSVoidResult at Microsoft.JSInterop.JSRuntime.<InvokeAsync>d__161[[Microsoft.JSInterop.Infrastructure.IJSVoidResult, Microsoft.JSInterop, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60]].MoveNext() at Microsoft.JSInterop.JSRuntimeExtensions.InvokeVoidAsync(IJSRuntime , String , Object[] ) at Microsoft.AspNetCore.Components.WebAssembly.Authentication.RemoteAuthenticationService3.<EnsureAuthService>d__29[[Microsoft.AspNetCore.Components.WebAssembly.Authentication.RemoteAuthenticationState, Microsoft.AspNetCore.Components.WebAssembly.Authentication, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60],[Microsoft.AspNetCore.Components.WebAssembly.Authentication.RemoteUserAccount, Microsoft.AspNetCore.Components.WebAssembly.Authentication, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60],[Microsoft.Authentication.WebAssembly.Msal.Models.MsalProviderOptions, Microsoft.Authentication.WebAssembly.Msal, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60]].MoveNext() at Microsoft.AspNetCore.Components.WebAssembly.Authentication.RemoteAuthenticationService3.<GetAuthenticatedUser>d__28[[Microsoft.AspNetCore.Components.WebAssembly.Authentication.RemoteAuthenticationState, Microsoft.AspNetCore.Components.WebAssembly.Authentication, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60],[Microsoft.AspNetCore.Components.WebAssembly.Authentication.RemoteUserAccount, Microsoft.AspNetCore.Components.WebAssembly.Authentication, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60],[Microsoft.Authentication.WebAssembly.Msal.Models.MsalProviderOptions, Microsoft.Authentication.WebAssembly.Msal, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60]].MoveNext() at Microsoft.AspNetCore.Components.WebAssembly.Authentication.RemoteAuthenticationService3.<GetUser>d__27[[Microsoft.AspNetCore.Components.WebAssembly.Authentication.RemoteAuthenticationState, Microsoft.AspNetCore.Components.WebAssembly.Authentication, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60],[Microsoft.AspNetCore.Components.WebAssembly.Authentication.RemoteUserAccount, Microsoft.AspNetCore.Components.WebAssembly.Authentication, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60],[Microsoft.Authentication.WebAssembly.Msal.Models.MsalProviderOptions, Microsoft.Authentication.WebAssembly.Msal, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60]].MoveNext() at Microsoft.AspNetCore.Components.WebAssembly.Authentication.RemoteAuthenticationService`3.<GetAuthenticationStateAsync>d__19[[Microsoft.AspNetCore.Components.WebAssembly.Authentication.RemoteAuthenticationState, Microsoft.AspNetCore.Components.WebAssembly.Authentication, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60],[Microsoft.AspNetCore.Components.WebAssembly.Authentication.RemoteUserAccount, Microsoft.AspNetCore.Components.WebAssembly.Authentication, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60],[Microsoft.Authentication.WebAssembly.Msal.Models.MsalProviderOptions, Microsoft.Authentication.WebAssembly.Msal, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60]].MoveNext() at Microsoft.AspNetCore.Components.Authorization.AuthorizeViewCore.OnParametersSetAsync() at Microsoft.AspNetCore.Components.ComponentBase.CallStateHasChangedOnAsyncCompletion(Task task) at Microsoft.AspNetCore.Components.ComponentBase.RunInitAndSetParametersAsync()

Ft @ blazor.webassembly.js:1
Ft @ blazor.webassembly.js:1
Developer technologies | .NET | Blazor
0 comments No comments

Answer accepted by question author
  1. Jack Dang (WICLOUD CORPORATION) 16,515 Reputation points Microsoft External Staff Moderator
    2026-03-02T04:46:30.1966667+00:00

    Hi @ta ,

    Thanks for reaching out.

    I looked at the error you’re seeing:

    Unhandled exception rendering component: NullabilityInfoContext_NotSupported
    

    This happens in Blazor WebAssembly apps running on .NET 8 when the JSON serializer tries to inspect nullability metadata at runtime. In simple terms, your app is trying to convert some C# objects to JSON during authentication (MSAL login), and the WebAssembly runtime doesn’t fully support the way .NET 8 checks nullability, especially when reflection or object-typed properties are involved.

    A few things are happening under the hood:

    • Blazor is serializing authentication state or user data to send it to JavaScript.
    • System.Text.Json in .NET 8 inspects property nullability using NullabilityInfoContext.
    • WebAssembly trimmed builds remove some metadata needed for this inspection.
    • As a result, the serializer throws NullabilityInfoContext_NotSupported.

    I would suggest a few approaches:

    1. Use source-generated JSON:
      • Create a JsonSerializerContext for your types instead of relying on runtime reflection. This avoids the nullability inspection entirely.
         [JsonSerializable(typeof(YourType))]
         public partial class AppJsonContext : JsonSerializerContext { }
      
      And then serialize like this:
         var options = new JsonSerializerOptions
         {
             TypeInfoResolver = AppJsonContext.Default
         };
      
    2. Avoid object or object[] properties in your authentication models. Strongly typed classes work much better with Blazor WebAssembly and trimming.
    3. If you just want to confirm trimming is the issue, you can temporarily disable it in your .csproj:
         <PublishTrimmed>false</PublishTrimmed>
      
      This increases app size, so it’s mainly for testing.
    4. Keep packages up to date, especially:
      • Microsoft.Authentication.WebAssembly.Msal
      • Microsoft.AspNetCore.Components.WebAssembly.Authentication

    Note: The code snippets provided are for reference only and may need to be adapted to your specific project structure and types.

    Hope this helps! If my answer was helpful - kindly follow the instructions here so others with the same problem can benefit as well.


Answer accepted by question author
  1. Q&A Assist
    2026-02-27T15:50:22.48+00:00
    AI generated content. This question contains an answer created with AI from Q&A Assist. Learn more

    The exception occurs while Blazor WebAssembly is rendering and running authentication logic, and it is fatal to the component’s render/circuit.

    From the stack trace:

    • The failure happens inside System.Text.Json when it tries to determine nullability metadata (NullabilityInfoContext) for a type being serialized for JS interop.
    • The error surfaces as an unhandled exception during component rendering and then bubbles up through AuthorizeViewCore.OnParametersSetAsync() and the Blazor renderer.

    In Blazor, unhandled exceptions in rendering or lifecycle methods are fatal:

    • Rendering logic exceptions (for example, anything that happens while building the render tree or calling into services used by the UI) terminate the circuit or component render.
    • Lifecycle methods like OnParametersSetAsync are also fatal if they throw.

    In this case, the RemoteAuthenticationService used by AuthorizeView is calling into JS via IJSRuntime.InvokeVoidAsync, which triggers JSON serialization of an object graph that uses nullability metadata not supported in the current runtime/target combination, causing NullabilityInfoContext_NotSupported.

    To resolve:

    1. Ensure the app is targeting a supported .NET runtime and browser combination for the NullabilityInfoContext feature used by System.Text.Json (for example, align the project’s target framework and runtime with the SDK/runtime actually deployed to the client).
    2. If the error started after upgrading .NET or packages, clear and rebuild to remove incoherent assemblies:
      • Clear NuGet caches: dotnet nuget locals all --clear.
      • Delete bin and obj folders.
      • Restore and rebuild the project.
      • Redeploy, ensuring the deployment folder is fully cleaned before copying new files.
    3. If custom JSON options or custom converters are registered for authentication or JS interop payloads, temporarily remove or simplify them to isolate which type or configuration triggers NullabilityInfoContext.
    4. Because the exception is thrown during rendering/authentication state evaluation, wrap any custom logic used by AuthorizeView or authentication-related components in try-catch with logging to avoid additional unhandled exceptions in lifecycle methods.

    Once the runtime/package mismatch or problematic type configuration is corrected, the AuthorizeView and authentication components should render without triggering the fatal rendering exception.


    References:

1 additional answer

Sort by: Most helpful
  1. ta 40 Reputation points
    2026-03-11T05:09:14.4233333+00:00

    I resolved this by adding these lines to .csproj file. User's image

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.