次の方法で共有


FaultContract in Indigo

FaultContract is an attribute that can be defined on the ServiceContract to define faults sent across the wire in Indigo.  Indigo does not reflect exceptions directly across the wire, if you want faults to be thrown to your client you must use the Fault system.  An exception will cause your service to behave in other ways, most likely it will failfast the service and cause the connection to be disconnected.

When using a Fault you define fault contract liek this:  [FaultContract(typeof(DivideByZeroException))].  When you throw the fault you do it like this:  throw new Fault<DivideByZeroException>(exception).  You do not specificy the complete fault type in the contract, just the part inside the Fault<>.  If you do this: [FaultContract(typeof(Fault<DivideByZeroException>))] you will need to throw a fault like this: throw new Fault<Fault<DivideByZeroException>>, this problem got me once :)

Faults can define any type as an input, they do not need to define an exception specifically.