Note i have seen these list here
try
{
// Some code......
}
catch (CommunicationException exception) // WCF Exception
{
}
catch (TimeoutException exception) // WCF Exception -
{
}
catch (Exception ex)
{
// Standard exception
}
In a WCF Client, you can capture exceptions thrown from a service catching a FaultException. You can also catch any other class of error if you want special handling (ie, TimeoutException or CommunicationException).
Here's an example:
proxy ServiceClient();
try
{
proxy = new ServiceClient();
proxy.DoSomething();
}
catch (FaultException ex)
{
// handle errors returned by WCF service
}
catch (CommunicationException ex)
{
// handle communication errors here
}
catch (TimeOutException ex)
{
// handle timeouts here
}
catch (Exception ex)
{
// handle unaccounted for exception here
}
finally
{
if (proxy.State == CommunicationState.Opened)
{
proxy.Close();
}
else
{
proxy.Abort();
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.