2017-07-19 14 views
0

これで、いくつかの例外処理をプログラムに追加しようとしていました。私はこれをデバッグする場合、条件TypeOf関数exがServiceModel.CommunicationExceptionがTrueですVb.Net例外のフィルタリングCommunicationExceptionとServiceModel.FaultExceptionの比較

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) 

、しかし:

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 

そして、次の例外は、このコードブロックの中に落ちたときに驚いた:私は、次のキャッチを追加しました私はスタックトレースまたは例外メッセージのどこにでもその例外を見つけることができません。誰でもこれを説明できますか? 「:...基になる接続が閉じられました」または「既存の接続はリモートホストに強制的に切断された」

答えて

1

FaultException継承をCommunicationExceptionから、そして「objectexpression場合TypeOf演算子はtrueを返し、私はのようなものをキャッチしようとしています型名がtypenameであるか型名から継承されています。 "この場合、正しいことはTypeOf ex Is ServiceModel.CommunicationExceptionです。

関連する問題