Skip to Content
Programming WCF Services
book

Programming WCF Services

by Juval Lowy
February 2007
Intermediate to advanced
634 pages
16h 1m
English
O'Reilly Media, Inc.
Content preview from Programming WCF Services

Error-Handling Extensions

WCF enables developers to customize the default exception reporting and propagation, and even provide for a hook for custom logging. This extensibility is applied per channel dispatcher, although you are more than likely to simply utilize it across all dispatchers.

To install your own error-handling extension, you need to provide the dispatchers with an implementation of the IErrorHandler interface defined as:

public interface IErrorHandler
{
   bool HandleError(Exception error);
   void ProvideFault(Exception error,MessageVersion version,ref Message fault);
}

Any party can provide this implementation, but typically it will be provided either by the service itself or by the host. In fact, you can have multiple error-handling extensions chained together. You will see later in this section just how to install the extensions.

Providing a Fault

The ProvideFault( ) method of the extension object is called immediately after any exception is thrown by the service or any object on the call chain down from a service operation. WCF calls ProvideFault( ) before returning control to the client and before terminating the session (if present) and before disposing of the service instance (if required). Because ProvideFault( ) is called on the incoming call thread while the client it still blocked waiting for the operation to complete, you should avoid lengthy execution inside ProvideFault( ).

Using ProvideFault( )

ProvideFault( ) is called regardless of the type of exception ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Programming WCF Services, 2nd Edition

Programming WCF Services, 2nd Edition

Juval Lowy
Pro WCF: Practical Microsoft SOA Implementation

Pro WCF: Practical Microsoft SOA Implementation

Chris Peiris, Dennis Mulder, Shawn Cicoria, Amit Bahree, Nishith Pathak
Mastering ASP.NET Web API

Mastering ASP.NET Web API

Mithun Pattankar, Malendra Hurbuns

Publisher Resources

ISBN: 0596526997Supplemental ContentErrata Page