IErrorhandler not returning to Client

198 views Asked by At

I'm trying to implement the IErrorhandler which is proving to be a real pain!

I have imlpement the provideFault method from the IErrorhandler interface like so...

    public void ProvideFault(Exception error, MessageVersion version, ref Message fault)
    {
        FaultException<ServiceFault> faultException = ServiceMethods.BuildFaultException<ServiceFault>("Provide Fault Error", error.Message);
        MessageFault messageFault = faultException.CreateMessageFault();

        fault = Message.CreateMessage(version, messageFault, faultException.Action);
    }

If my service operations hit an exception it drops into this method to create a FaultException. My problem is the client doesnt get this FaultException returned to them.

Am I missing something obvious here?

Thanks in advance

2

There are 2 answers

0
Alberto Solano On

I've a little experience with WCF, but I think that you're just creating a message and you're not sending it through a request or a response. I think for this reason your client doesn't get the message with the exception.

Did you implement the method HandleError of the IErrorHandler interface?

Your question is similar to these questions already asked in SO:

Maybe they can help you.

Read also this thread in MSDN.

0
Filippo Pensalfini On

If you are not seeing a FaultException<ServiceFault> client-side, double check that you are not missing the fault contract on your service:

[ServiceContract]
public interface IHelloService
{
    [OperationContract]
    [FaultContract(typeof(ServiceFault))]
    void DoWork();
}