Handling exceptions the right way in WCF (part 2)
In my previous post I talked about FaultExceptions and how they are transmitted from the server to the client. First, let's have a look at the sample service contract : [ServiceContract] public interface ITimeService { [OperationContract] [FaultContract(typeof(TimeExceptionDetails))] DateTime GetTime(); } The service implementation : public class TimeService : ITimeService { #region ITimeService Members public DateTime GetTime() { return DateTime.Now; } #endregion } And the Fault details class : public class TimeExceptionDetails { public static readonly TimeExceptionDetails Default = new TimeExceptionDetails(); [DataMember] public String Message { get; private set; } public TimeExceptionDetails() { this.Message = "There is a problem in the spacetime continuum, Marty"; } public TimeExceptionDetails(String message) { this.Message = message; } } Now we'll learn how to ease the process of creating FaultExceptions by using the IE...