locked
Fault Exception error - The creator of this fault did not specify a Reason RRS feed

  • Question

  •  All,

    I'm using the following fault exception but I keep get this when my code executes the "throw new FaultException<ShoppingCartServiceFault>(cartFault)" - why is this line fail? I have also tried to add a new reasoncode but that doesn't work as well.

    Any help would be welcome.

    Hammer

    catch
    (System.Exception ex)

    {

    ShoppingCartServiceFault cartFault = new ShoppingCartServiceFault();

    cartFault.Operation = "AddItem";

    cartFault.Reason = "Exception in the AddItem Method";

    cartFault.details = ex.Message;

    throw new FaultException<ShoppingCartServiceFault>(cartFault);

    }


    Carl Evans
    Wednesday, October 15, 2008 9:21 PM

Answers

  • All,

    I found out the why my service fault is throw an error and here is a link to the explanation

    http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=302017

    It appears that when you're using VS and your debugging your code as I was, the fault exception will throw a FaultException was unhandled by user code. When I press continue, the correct error is then report back to the client.

    I personally find it hard to believe that it's by design and lends itself to be confusing because I actually believe that something was wrong with my FaultException class. Now 2 days later, its all by design.... Shessh already....


    Thanks to all for responsing.


    Hammer

    Carl Evans
    • Proposed as answer by Phani_tpk Sunday, October 19, 2008 12:43 AM
    • Marked as answer by Tao Xie - MSFT Tuesday, October 28, 2008 1:31 AM
    Friday, October 17, 2008 3:36 PM

All replies

  • This should have worked. Can you please specicy what is the exact error message you are getting?

    -Phani
    Thursday, October 16, 2008 8:00 PM
  • Phani,


    The error message I get when it throws my fault exception is unhandle exception and it's message is "The creator of this fault did not specify a Reason". I have no idea what that means. I have google this phase and it appears a few other developers have had this issue but I have not came across anyone having resolved it.

    If I have can understand why it happen, I may be able to eliminate it but, for now, I don't have an anwers.


    Hammer
    Carl Evans
    Friday, October 17, 2008 1:34 PM
  • Does your service contract specify the fault contract on the operation?
    [FaultContract()]

    If not, it will be treated as an unhandled/unexpected exception.
    Friday, October 17, 2008 1:40 PM
  • All,

    I found out the why my service fault is throw an error and here is a link to the explanation

    http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=302017

    It appears that when you're using VS and your debugging your code as I was, the fault exception will throw a FaultException was unhandled by user code. When I press continue, the correct error is then report back to the client.

    I personally find it hard to believe that it's by design and lends itself to be confusing because I actually believe that something was wrong with my FaultException class. Now 2 days later, its all by design.... Shessh already....


    Thanks to all for responsing.


    Hammer

    Carl Evans
    • Proposed as answer by Phani_tpk Sunday, October 19, 2008 12:43 AM
    • Marked as answer by Tao Xie - MSFT Tuesday, October 28, 2008 1:31 AM
    Friday, October 17, 2008 3:36 PM