WCF Example (4)

Source: Internet
Author: User

Exception handling (Exception, FaultException, FaultException, Ierrorhandler)

Introduced

WCF (Windows communication Foundation)-Exception handling: General exception processing, faultexception and faultexception throwing and handling, Use Ierrorhandler to handle exceptions.

Example

1. Service

IHello.cs

Using System;
Using System.Collections.Generic;
Using System.Linq;
Using System.Text;
Using System.ServiceModel;
Namespace WCF. Servicelib.exception
{
/**////<summary>
///Ihello interface
///</summary>
[SERVICEC ONTRACT] public
interface Ihello
{
/**////<summary>
///Throw exception exception
///    </summary>
[OperationContract]
void Helloexception ();
/**////<summary>
///throw faultexception exception
///</summary>
[OperationContract]
void Hellofaultexception ();
/**////<summary>
///throws faultexception<t> exception
///</summary>
[OperationContract    ]
[Faultcontract (typeof (Faultmessage))]
void Hellofaultexceptiongeneric ();
/**////<summary>
///ierrorhandler processing exception
///</summary>
[OperationContract]
void Helloierrorhandler ();
}
}          

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.