gpt4 book ai didi

c# - List 缺少 .NET Native 序列化代码

转载 作者:太空宇宙 更新时间:2023-11-03 15:25:17 25 4
gpt4 key购买 nike

在 Windows 10 通用应用程序中,我在尝试使用 DataContractSerializer 时遇到错误

Type 'System.Collections.Generic.List`1[System.SByte]' cannot be serialized, serialization code for the type is missing.Consult the SDK documentation for adding it as a root serialization type.

我没有直接使用 DCS,而是在 WCF 调用服务操作的上下文中使用。

我一直无法弄清楚哪些运行时指令可以解决这个问题。以下内容没有帮助:

<Type Name="System.Collections.Generic.List{System.SByte}" 
Dynamic="Required Public"
DataContractSerializer="Required Public"
Browse="Required All"
Serialize="Required All"/>

最佳答案

根据文档 ( https://msdn.microsoft.com/en-us/library/dn627478(v=vs.110).aspx ),您对 List<SByte> 的声明是不正确的。您只需指出通用参数的数量,而不是它们的实际类型:

<Type Name="System.Collections.Generic.List`1" ... />

关于c# - List<T> 缺少 .NET Native 序列化代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35588060/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com