简体   繁体   中英

IErrorhandler not returning to Client

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

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();
}

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM