【问题标题】:Finding the Web Method responsible for WCF Communication Exception查找导致 WCF 通信异常的 Web 方法
【发布时间】:2013-04-12 08:27:29
【问题描述】:

我正在尝试查找负责引发间歇性System.ServiceModel.CommunicationException 异常的 Web 方法(Web 应用程序有数百个)的名称。

我有一个可以捕获异常的错误处理程序 (IErrorHandler),但异常信息并未将我指向异常的来源。

有什么方法可以确定哪个 web 方法导致了异常?

唯一的堆栈跟踪信息如下:

System.ServiceModel.CommunicationException:从管道读取错误:无法识别的错误 109 (0x6d)。 ---> System.IO.PipeException:从管道读取错误:无法识别的错误 109 (0x6d)。
在 System.ServiceModel.Channels.PipeConnection.OnAsyncReadComplete(布尔 hasResult,Int32 错误,Int32 numBytes)
--- 内部异常堆栈跟踪结束 ---
在 System.Runtime.AsyncResult.End[TAsyncResult](IAsyncResult 结果)
在 System.ServiceModel.Channels.TransportDuplexSessionChannel.TryReceiveAsyncResult.End(IAsyncResult 结果,消息和消息)
在 System.ServiceModel.Dispatcher.DuplexChannelBinder.EndTryReceive(IAsyncResult 结果,RequestContext& requestContext)
在 System.ServiceModel.Dispatcher.ErrorHandlingReceiver.EndTryReceive(IAsyncResult 结果,RequestContext& requestContext)

谢谢

【问题讨论】:

  • 你能用visual studio来调试吗?你看过异常的堆栈跟踪吗?
  • 是的,我可以,但堆栈跟踪并未指明实际的 Web 方法源。
  • @peer - 不幸的是,内部异常也没有任何有用的信息,只有There was an error reading from the pipe: Unrecognized error 109 (0x6d)
  • 尝试配置tracing:[Tracing][1] [1]:msdn.microsoft.com/en-us/library/ms733025.aspx

标签: c# wcf


【解决方案1】:

Visual Studio 2010 可以在您调试时捕获异常。您可以捕获任何一组或全部异常。也可以在执行引发异常的操作之前启用捕获。

假设您使用的是 Visual Studio 2010:

  1. 在顶部菜单栏中,点击调试,下一步点击异常。
  2. 点击打开Common language runtime exceptions部分。
  3. 向下滚动直到找到System.ServiceModel,也点击打开。
  4. 在对应异常的复选框中打勾

如果可能,我还建议在可能导致此错误的方法中添加某种日志记录。这样,更容易确定问题的位置。

【讨论】:

  • 捕获异常不是问题。问题是我无法将异常与原始 Web 方法调用联系起来。
  • 好的,您可以在Visual Studio 中查看调用堆栈窗口吗?或许可以为您提供一些信息?
猜你喜欢
  • 2011-10-17
  • 1970-01-01
  • 1970-01-01
  • 2011-06-27
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多