Answered specified cast is not valid?

  • Wednesday, May 07, 2008 7:19 PM
     
     

    Can anyone help with this?

     

    Thanks

     

    Exception Details: System.InvalidCastException: Specified cast is not valid.

    Source Error:

    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

    Stack Trace:

    [InvalidCastException: Specified cast is not valid.]
       WorkFlow.ApprovalPathBuilder.DataGrid_Edit(Object sender, DataGridCommandEventArgs E) +253
       System.Web.UI.WebControls.DataGrid.OnEditCommand(DataGridCommandEventArgs e) +110
       System.Web.UI.WebControls.DataGrid.OnBubbleEvent(Object source, EventArgs e) +466
       System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +26
       System.Web.UI.WebControls.DataGridItem.OnBubbleEvent(Object source, EventArgs e) +100
       System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +26
       System.Web.UI.WebControls.LinkButton.OnCommand(CommandEventArgs e) +121
       System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +115
       System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +18
       System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +138
       System.Web.UI.Page.ProcessRequestMain() +1292
    

Answers

  • Thursday, May 08, 2008 7:20 AM
     
     Answered
    What is an InvalidCastException? It's .NET telling you that an assertion about the type of an object is incorrect. For example if you have the two types Dog and Cat, and you have an object that is of type Dog, then if you cast it to a Cat you'll get an InvalidCastException because it isn't a Cat, it's a Dog.

    The code is asserting that an object is of a particular type when it isn't. It's a bug in the code.

    If you don't own the code you'll need to get in touch with whoever did and get them to fix it.

All Replies

  • Wednesday, May 07, 2008 7:55 PM
     
     
    It's pretty much what the error message tells you. You're performing an invalid cast on line 253 of ApprovalPathBuilder.
  • Wednesday, May 07, 2008 8:22 PM
     
     

    But what is that? When our customers place orders on our website, they get this error message when they checkout and the order doesnt process. This just started yesterday out of the blue and this has never happened before. Thanks

  • Thursday, May 08, 2008 7:20 AM
     
     Answered
    What is an InvalidCastException? It's .NET telling you that an assertion about the type of an object is incorrect. For example if you have the two types Dog and Cat, and you have an object that is of type Dog, then if you cast it to a Cat you'll get an InvalidCastException because it isn't a Cat, it's a Dog.

    The code is asserting that an object is of a particular type when it isn't. It's a bug in the code.

    If you don't own the code you'll need to get in touch with whoever did and get them to fix it.