使用WebService类作为WCF参数时出现序列化错误

本文关键字:序列化 错误 参数 WCF WebService 使用 | 更新日期: 2023-09-27 18:06:13

当我运行服务时,我得到奇怪的错误。SVC文件:我使用了一个类(来自另一个Webservice)作为函数的参数。如果我在界面中注释了这个函数,它会工作得很好。

 Type cannot inherit from a type that is not marked with DataContractAttribute or SerializableAttribute.  Consider marking the base type  with DataContractAttribute or SerializableAttribute, or removing them from the derived type.

有人能帮我一下吗?

提前和对不起,我的英语不好。

使用WebService类作为WCF参数时出现序列化错误

我认为Marc是正确的,也许有一个误解。他/我认为你正在消费一个web服务,并在你正在编写的另一个wcf web服务中重用来自同一web服务(你可能为其生成代码)的类作为参数。

实际上,生成错误的类型可能没有它所需要的DataContractAttribute。