C#C
C#7mo ago
9 replies
Neko Boi Nick

System.Text.Json JsonConverter<T> Throwing ArgumentExeception and TargetInvocationException

I am having a strange issue where my System.Text.Json.Serialization.JsonConverter<JsonEntries> is throwinng two exceptions:
System.ArgumentException with message:
Value does not fall within the expected range.
and
System.Reflection.TargetInvocationException with message:
Exception has been thrown by the target of an invocation.
here is the stack trace and example converter:
https://gist.github.com/thakyZ/c29ad07ed0eaa57b1d832305a2f55904

using .net 9 version 9.0.6
using System.Text.Json version 9.0.6

it would appear it is being thrown when the JsonSeralizer is trying to create an instance of the JsonConverter via Activate.CreateInstance
Was this page helpful?