簡體   English   中英

Vb.Net異常過濾CommunicationException與ServiceModel.FaultException

[英]Vb.Net Exception Filtering CommunicationException vs ServiceModel.FaultException

好的,所以我試圖在程序中添加一些異常處理並得到一些奇怪的行為。 我添加了以下內容:

Catch ex As Exception When TypeOf ex Is IOException _
    OrElse TypeOf ex Is TimeoutException _
    OrElse TypeOf ex Is ServiceModel.EndpointNotFoundException _
    OrElse TypeOf ex Is ServiceModel.ServerTooBusyException _
    OrElse TypeOf ex Is ServiceModel.CommunicationException

當以下異常落入此代碼塊時,我感到很驚訝:

System.ServiceModel.FaultException: System.Web.Services.Protocols.SoapException: There was an exception running the extensions specified in the config file. ---> System.Web.HttpException: Maximum request length exceeded.
at System.Web.HttpRequest.GetEntireRawContent()
at System.Web.HttpRequest.get_InputStream()
at System.Web.Services.Protocols.SoapServerProtocol.Initialize()
--- End of inner exception stack trace ---
at System.Web.Services.Protocols.SoapServerProtocol.Initialize()
at System.Web.Services.Protocols.ServerProtocolFactory.Create(Type type, HttpContext context, HttpRequest request, HttpResponse response, Boolean& abortProcessing)
Server stack trace:
at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

當我對此進行調試時,條件TypeOf ex是ServiceModel.CommunicationException為True,但在堆棧跟蹤或異常消息中的任何地方都找不到該異常。 有人可以解釋嗎? 我正在嘗試捕獲諸如“基礎連接已關閉:...”或“現有連接被遠程主機強行關閉”之類的信息

FaultException繼承自CommunicationException ,如果“ objectexpression的類型類型為typename或從typename繼承”,則TypeOf運算符返回true,因此在這種情況下, TypeOf ex Is ServiceModel.CommunicationException是正確的。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM