本文整理匯總了VB.NET中System.ServiceModel.CommunicationException類的典型用法代碼示例。如果您正苦於以下問題:VB.NET CommunicationException類的具體用法?VB.NET CommunicationException怎麽用?VB.NET CommunicationException使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了CommunicationException類的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的VB.NET代碼示例。
示例1: Client
' 導入命名空間
Imports System.ServiceModel
Imports System.ServiceModel.Channels
Imports Microsoft.WCF.Documentation
Public Class Client
Public Shared Sub Main()
' Picks up configuration from the configuration file.
Dim wcfClient As New SampleServiceClient()
Try
' Making calls.
Console.WriteLine("Enter the greeting to send: ")
Dim greeting As String = Console.ReadLine()
Console.WriteLine("The service responded: " & wcfClient.SampleMethod(greeting))
Console.WriteLine("Press ENTER to exit:")
Console.ReadLine()
Catch timeProblem As TimeoutException
Console.WriteLine("The service operation timed out. " & timeProblem.Message)
wcfClient.Abort()
Console.ReadLine()
' Catch the contractually specified SOAP fault raised here as an exception.
Catch greetingFault As FaultException(Of GreetingFault)
Console.WriteLine(greetingFault.Detail.Message)
Console.Read()
wcfClient.Abort()
' Catch unrecognized faults. This handler receives exceptions thrown by WCF
' services when ServiceDebugBehavior.IncludeExceptionDetailInFaults
' is set to true.
Catch faultEx As FaultException
Console.WriteLine("An unknown exception was received. " & faultEx.Message + faultEx.StackTrace)
Console.Read()
wcfClient.Abort()
' Standard communication fault handler.
Catch commProblem As CommunicationException
Console.WriteLine("There was a communication problem. " & commProblem.Message + commProblem.StackTrace)
Console.Read()
wcfClient.Abort()
End Try
End Sub
End Class