[RESOLVED] wcf 4.0 trouble with FaultContracts.
Hi All,
My duplex wcf service works a treat when everything is fine. Now I'm trying to introduce some error handling.
my interface has the following:
[
Code:
ServiceContract(CallbackContract = typeof(IRatabaseXmlReturn), SessionMode = SessionMode.Required)]
public interface IRatabaseService
{
[OperationContract(IsOneWay = false)]
[FaultContract(typeof(Exception))]
[FaultContract(typeof(ApplicationException))]
void Rates(string data);
}
public interface IRatabaseXmlReturn
{
[OperationContract(IsOneWay = true)]
void OnRatabaseCallback(string XmlReturn);
}
Now in my Rates Method in a catch block I have the following :
Code:
throw new FaultException<Exception>(ex, new FaultReason(ex.Message), new FaultCode("Sender"));
The client code that uses the service has a catch block of:
....
Code:
catch (FaultException<Exception> ef) //this will be raised by the service if there's an error in the service
{
throw ef.Detail;
}
catch (CommunicationException cex)
{
RateService.Abort();
throw cex;
}.....
Now when my code hits the throw new FaultException in my service (debug mode). I recieve an error :FaultException was unhandled by user code.
What am I doing wrong?
Re: wcf 4.0 trouble with FaultContracts.
Ok, I found the answer. There appears to be a bug in the IDE. When using FaultExceptions, you need to turn off 'Enable the exception assistant' and 'enable Just My Code' in the General section of Debugging from tools option menu