Skip to content

FATAL UNHANDLED EXCEPTION: System.InvalidOperationException: JsonSerializerIsReflectionDisabled in .NET for Android #106347

Closed Answered by elgonzo
FANMixco asked this question in Q&A
Discussion options

You must be logged in to vote

I am not sure what other class you are referring to, but JsonSerializer.Deserialize<List<int>>(selected) doesn't use a (source-generated) serialization context. You need to use a serialization context that is aware of the root type you are trying to deserialize into. In this case the root type here is List<int>. (If you are using a serialization context that isn't aware of the root type for deserialization, the deserializer would throw an exception informing you about this fact, by the way...)

You don't necessarily need to create separate serialization context classes (but you can), as you can let a single serialization context class handle multiple root types by simply using multiple [Js…

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
3 replies
@eiriktsarpalis
Comment options

@FANMixco
Comment options

@elgonzo
Comment options

Answer selected by FANMixco
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
4 participants
Converted from issue

This discussion was converted from issue #106339 on August 13, 2024 16:58.