【问题标题】:WCF Proxy generationWCF 代理生成
【发布时间】:2010-12-20 06:34:14
【问题描述】:

我正在使用 svcutil 工具生成代理。我的合约方法返回特定类型的对象。 但是,生成的代理客户端接口具有对象类型的返回值。 更重要的是,我收到消息异常:

System.ServiceModel.FaultException`1[System.ServiceModel.ExceptionDetail] : The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter http://tempuri.org/:name. The InnerException message was 'XML 'Element' 'http://tempuri.org/:name' does not contain expected attribute 'http://schemas.microsoft.com/2003/10/Serialization/:Type'. The deserializer has no knowledge of which type to deserialize. Check that the type being serialized has the same contract as the type being deserialized.'.  Please see InnerException for more details.

有什么想法吗?

【问题讨论】:

  • 您是否按照提示检查了内部异常?它说什么?

标签: c# proxy datacontract svcutil.exe


【解决方案1】:

听起来 svcutil 无法理解您的类型。如果您在其他程序集中定义了自定义类型,您可能需要使用 [KnownType] 属性来告诉 svcutil 发生了什么。

请参阅 MSDN 参考资料here

【讨论】:

  • 嗯,现在我注意到服务返回的类型没有用 DataContract 属性修饰...这是问题吧?
  • 这似乎很有可能 - 试试吧!
  • 嗯,那个服务返回接口。接口不能用 DataContract 属性修饰。那我该怎么办?
【解决方案2】:

嗯,我是 WCF 的新手,我正在探索的项目......但是我刚刚注意到服务返回的数据类型没有用 DataContract 属性修饰。是这个问题吗?

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-08-21
    • 1970-01-01
    • 1970-01-01
    • 2011-04-03
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多