gpt4 book ai didi

wcf - .NET 基类型不能被 WCF 序列化

转载 作者:行者123 更新时间:2023-12-04 14:36:11 25 4
gpt4 key购买 nike

我正在编写 WCF 服务并希望公开一些自定义配置元素(例如自定义 ConfigurationSection 和 ConnectionStringSettings),以便我可以修改服务的配置。

我的自定义配置元素之一继承自 System.Configuration.ConfigurationElementCollection .当我尝试启动我的 WCF 服务时,我收到以下错误消息...

Type 'System.Configuration.ConfigurationElementCollection' cannot be serialized. Consider marking it with the DataContractAttribute attribute, and marking all of its members you want serialized with the DataMemberAttribute attribute.



有没有办法为这种类型实现 DataContract?我用 [DataContract] 属性标记了我继承的类。

最佳答案

今天刚碰到这个问题。这很令人困惑,因为问题出在将项目从一台机器转移到另一台机器上。这篇文章似乎相关:

http://blogs.msdn.com/youssefm/archive/2009/08/10/serializing-plain-old-clr-objects-poco-types-with-datacontractserializer.aspx

总而言之,在链接失效的情况下,该问题似乎在运行时 3.5 中出现并在运行时 3.5 SP1 中消失。

关于wcf - .NET 基类型不能被 WCF 序列化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/250255/

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