最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

.net - dotnet 8 maui ios NullabilityInfoContext Not Supported - Stack Overflow

programmeradmin1浏览0评论

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 badge
Add a comment  | 

1 Answer 1

Reset to default 1

Couldn't get it to work in .Net 8, but changing to .Net 9 solved the problem.

发布评论

评论列表(0)

  1. 暂无评论