小编Kee*_*ler的帖子

当我不使用“System.IntPtr”时,为什么 System.Text.Json 会为“System.IntPtr”抛出“NotSupportedException”?

我有一个 .NET Framework 4.8 / AngularJS 应用程序,我正在尝试升级到 .NET 6,以便我可以开始尝试更新的前端框架(如 Blazor)。升级进展顺利,但当从 Angular JS 代码调用我的 API 方法之一时,我总是看到此错误:

System.NotSupportedException: Serialization and deserialization of 'System.IntPtr' instances are not supported. Path: $.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)
   at …
Run Code Online (Sandbox Code Playgroud)

c# asp.net-core system.text.json .net-6.0

21
推荐指数
1
解决办法
5万
查看次数

标签 统计

.net-6.0 ×1

asp.net-core ×1

c# ×1

system.text.json ×1