如何跟踪WCF序列化问题/异常 [英] How to trace WCF serialization issues / exceptions

查看:181
本文介绍了如何跟踪WCF序列化问题/异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我偶尔会碰到一个应用程序异常的WCF序列化过程中引发的(从我的OperationContract的返回DataContract后)的问题。唯一的(少meaningfull)消息我得到的是

I occasionally run into the problem that an application exception is thrown during the WCF-serialization (after returning a DataContract from my OperationContract). The only (and less meaningfull) message I get is

System.ServiceModel.CommunicationException   :基础连接是   关闭:连接被关闭   出乎意料的。

System.ServiceModel.CommunicationException : The underlying connection was closed: The connection was closed unexpectedly.

没有任何了解的内部异常,这使得它真的很难找出序列化过程中造成的错误。

without any insight to the inner exception, which makes it really hard to find out what caused the error during serialization.

是否有人知道一个很好的方法,你如何跟踪,记录和调试这些异常?甚至更好,我可以捕获异常,处理它们并发送一个定义FaulMessage到客户端?

Does someone know a good way how you can trace, log and debug these exceptions? Or even better can I catch the exception, handle them and send a defined FaulMessage to the client?

谢谢

推荐答案

您应该如果配置这样您的服务行为得到内部异常:

You should get the inner exception if you configure your service behavior like this:

<system.serviceModel>
     <behaviors>
         <serviceBehaviors>
               <behavior name="YourServiceBehaviour">
                   ...
                   <serviceDebug includeExceptionDetailInFaults="true" />
                   ...
               </behavior>
         </serviceBehaviors>
     </behaviors>
</system.serviceModel>

此外,您可以启用跟踪。没有找到好的文章了,但也许这可以让你开始:

Additionally you can enable tracing. Did not find a good article now, but maybe this gets you started:

<一个href="http://developers.de/blogs/damir_dobric/archive/2009/03/24/using-of-wcf-trace.aspx">http://developers.de/blogs/damir_dobric/archive/2009/03/24/using-of-wcf-trace.aspx

这篇关于如何跟踪WCF序列化问题/异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆