FaultContract problem

Topics: Service Factory Modeling Edition Forum
Apr 20, 2008 at 6:39 AM
Hi all ,



I wrote in my service implementation :



some code...



if(x==0)

throw new FaultException<MyCustomFault>(new MyCustomFault());



some code...



In the client side :



try

{

calling the service ...

}

catch(FaultException<MyCustomFault> ex)

{

MessageBox.Show(ex.Message);

}



The client code doesn't catch the exception from the service. I get in the service side "FaultException `1 was unhandled by user code.



What is the problem

Regards...

Apr 20, 2008 at 5:29 PM

Does your OperationContract have a FaultContract defined on it?

[ServiceContact]
public interface Service 
{
    [OperationContract]
    [FaultContract(typeof(MyCustomFault)]
    OperationResponse Operation(OperationRequest request);
}



wasimf wrote:
Hi all ,



I wrote in my service implementation :



some code...



if(x==0)

throw new FaultException<MyCustomFault>(new MyCustomFault());



some code...



In the client side :



try

{

calling the service ...

}

catch(FaultException<MyCustomFault> ex)

{

MessageBox.Show(ex.Message);

}



The client code doesn't catch the exception from the service. I get in the service side "FaultException `1 was unhandled by user code.



What is the problem

Regards...



Apr 21, 2008 at 7:40 AM
Hi ,
Yes I have, I used the web service software factory modeling edition.
When I put a return statement in the client code catch , the client hold the exception and every thing is ok.
Should I have to do this or there is something else.

Thanks...
Developer
Apr 21, 2008 at 1:04 PM
Not sure about your question. Can you post your client side code and add your comments there?

Thanks,
CF