question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

System.Text.Json NotSupportedException

See original GitHub issue

Exception message:

System.NotSupportedException: Serialization and deserialization of 'System.IntPtr' instances are not supported. Path: $.Data.Exception.TargetSite.MethodHandle.Value.
       ---> System.NotSupportedException: Serialization and deserialization of 'System.IntPtr' instances are not supported.
         at System.Text.Json.Serialization.Converters.UnsupportedTypeConverter`1.Write(Utf8JsonWriter writer, T value, JsonSerializerOptions options)
         at System.Text.Json.Serialization.JsonConverter`1.TryWrite(Utf8JsonWriter writer, T& value, JsonSerializerOptions options, WriteStack& state)
         at System.Text.Json.Serialization.Metadata.JsonPropertyInfo`1.GetMemberAndWriteJson(Object obj, WriteStack& state, Utf8JsonWriter writer)
         at System.Text.Json.Serialization.Converters.ObjectDefaultConverter`1.OnTryWrite(Utf8JsonWriter writer, T value, JsonSerializerOptions options, WriteStack& state)
         at System.Text.Json.Serialization.JsonConverter`1.TryWrite(Utf8JsonWriter writer, T& value, JsonSerializerOptions options, WriteStack& state

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:11 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
BrennanConroycommented, Mar 22, 2022

Feel free to close it if you think it’s not a problem, thanks again.

Yeah, I don’t think this is an issue in the framework code. If you’re curious what’s causing the issue you could try to view the exception being thrown from your API and see what types are on it that aren’t serializer friendly.

1reaction
danmoseleycommented, Mar 21, 2022

I am going to move this to ASP.NET. It seems the JSON serializer is working as expected, the caller is SystemTextJsonOutputFormatter.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why does System.Text.Json throw a ` ...
Your code is failing during serialization not deserialization because you are catching some inner exception and trying to serialize it with ...
Read more >
Serialization and deserialization of 'System.Type' instances ...
DataType. System.NotSupportedException: Serialization and deserialization of 'System.Type' instances are not supported. at System.Text.Json.
Read more >
Serialization and deserialization of 'System.IntPtr' instances ...
System.NotSupportedException: Serialization and deserialization of 'System.IntPtr' instances are not supported. at System.Text.Json.
Read more >
How to Serialize Exceptions as JSON in .NET
Serialize() on the exception object, we encounter a NotSupportedException : Serialization and deserialization of 'System.Reflection.MethodBase' ...
Read more >
Serialization and deserialization of 'System.Action' instances ...
System. NotSupportedException : Serialization and deserialization of ' System. ... Using JSON IN C#! Serialization & Deserialization made easy!
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found