I have a dotnet 8 Maui Blazor Hybrid application that I am trying to deploy to an iPad. The application runs fine on Windows and iOS in Debug mode and through visual studio 2022. I can deploy the app to the iPad in Debug mode and it runs fine. When I deploy the app to the iPad in Release mode (or build an ipa) I get an exception when trying to serialize an object using System.Text.Json. This only happens when deploying in Release mode.
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 ...
I have this in the MauiProgram CreateMauiApp()
AppContext.SetSwitch("System.Reflection.NullabilityInfoContext.IsSupported", true);
I've tried adding this to the csproj, but the app won't load (it shows the splash screen then pops)
<NullabilityInfoContextSupport>true</NullabilityInfoContextSupport>
Anyone else find a solution to this?
I have a dotnet 8 Maui Blazor Hybrid application that I am trying to deploy to an iPad. The application runs fine on Windows and iOS in Debug mode and through visual studio 2022. I can deploy the app to the iPad in Debug mode and it runs fine. When I deploy the app to the iPad in Release mode (or build an ipa) I get an exception when trying to serialize an object using System.Text.Json. This only happens when deploying in Release mode.
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 ...
I have this in the MauiProgram CreateMauiApp()
AppContext.SetSwitch("System.Reflection.NullabilityInfoContext.IsSupported", true);
I've tried adding this to the csproj, but the app won't load (it shows the splash screen then pops)
<NullabilityInfoContextSupport>true</NullabilityInfoContextSupport>
Anyone else find a solution to this?
Share Improve this question edited 21 hours ago dbc 117k26 gold badges262 silver badges386 bronze badges asked Jan 20 at 16:51 John AlexanderJohn Alexander 111 silver badge1 Answer
Reset to default 1Couldn't get it to work in .Net 8, but changing to .Net 9 solved the problem.