【问题标题】:Include Exceptions as DataMember for DataContractSerializer WCF C#将异常包含为 DataContractSerializer WCF C# 的 DataMember
【发布时间】:2013-05-14 16:48:07
【问题描述】:

我想从 WCF 返回 DataContract 中的一组异常,但它不起作用。

    [DataContract]
    public class ProcessResult
    {
        [DataMember]
        public ProcessStatus EndStatus { get; set; }

        [DataMember]
        public Exception[] CaughtExceptionList { get; set; }

        [DataMember]
        public string CowListXML { get; set; }

    }

当我调用 WCF 时,我得到了这个异常

The underlying connection was closed: The connection was closed unexpectedly.

我作为数据成员注释掉/忽略了例外列表,我能够完美地得到结果。

谢谢!

【问题讨论】:

  • 并非所有异常都是可序列化的。连接 WCF 服务的客户端是什么?
  • 现在我只是用 c# 中的控制台应用程序对其进行测试

标签: c# wcf exception-handling datacontractserializer datacontract


【解决方案1】:

我相信 ExceptionDetail 类是您正在寻找的。​​p>

【讨论】:

  • 知道如何将异常转换为 ExceptionDetail 吗?
猜你喜欢
  • 2012-04-22
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-01-11
相关资源
最近更新 更多