Results 1 to 2 of 2

Thread: [RESOLVED] wcf 4.0 trouble with FaultContracts.

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2000
    Location
    Dunmow,Essex,England
    Posts
    898

    Resolved [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?

  2. #2

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2000
    Location
    Dunmow,Essex,England
    Posts
    898

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width