Exception has been thrown by the target of an invocation

Last post 01-19-2009 6:16 PM by Mustang65. 5 replies.

Sort Posts:

  • Exception has been thrown by the target of an invocation

    02-01-2007, 10:01 AM
    • Member
      313 point Member
    • JessyEzzy
    • Member since 05-27-2005, 10:09 PM
    • Posts 100

    I have a scriptmanager and updatepanel, inside the panel is a gridview it's bound to an objectdatasource, when I click the select button in the grid I get the alert with the message "Exception has been thrown by the target invocation". How would I know the source of this error, or what is causing the error. Is there a way to get the real exception that occurred not just a message?

    Thanks

  • Re: Exception has been thrown by the target of an invocation

    02-02-2007, 8:26 AM
    Answer
    • Participant
      1,205 point Participant
    • michiel1978
    • Member since 07-15-2005, 8:58 AM
    • Posts 250
    Disable the ajax for a moment (EnablePartialRendering="false" on the scriptmanager).
    When you ask a question, remember to click "mark as answered" when you get a reply which answers your question; this ensures the right forum member gets credit below for being helpful (and makes search more relevant too).
  • Re: Exception has been thrown by the target of an invocation

    03-05-2007, 10:33 PM
    • Member
      10 point Member
    • bobthecoder
    • Member since 03-06-2007, 3:19 AM
    • Posts 5
    This error message is about as useful as a chocolate fireguard. Disabling the update panel is fine for development, and the few bugs that I stumble across while developing. But what about in a production situation. If I get my clients phoning up telling me the app won't work becuase an "Exception has been thrown by the target of an invocation", then I'll just explain to them how to disable AJAX so I can get a useful error message. AHH. No. I don't think so. Is there some way that you can actually pass the message text up to the popup box. Dev's like me are pretty reliant on the exception text. Especially as we often just write stuff and then it gets put into production without rigourous testing. Not ideal, but thats what happens in the real world outside of Redmond.
  • Re: Exception has been thrown by the target of an invocation

    03-08-2007, 7:19 AM
    • Member
      134 point Member
    • VR2
    • Member since 12-13-2006, 4:42 PM
    • UK
    • Posts 96

    Was this resolved at all? I have a similar issue:

    Steps to Reproduce

    1) I have a DB table with a column which is varchar(1024)

    2) I want this column to only contain unique strings

    3) So I add a trigger to the column to check for the data entered and use RaisError if any problems

    4) I setup my Datagrid/ObjectDataSource/BLL/DAL and all works fine in aspx, the page errors with the correct message.

    5) I add in an AJAX Update Panel and *it* (the ASP.NET AJAX Libraries) just spits out a JSON string containing an alert message "An exception occured by the the target of an invocation". THAT is not the correct error string.

    Why is it not? and how do I alter this behaviour to make it send a JSON string containing the correct Error message?

    Thank

  • Re: Exception has been thrown by the target of an invocation

    03-08-2007, 7:19 AM
    • Member
      134 point Member
    • VR2
    • Member since 12-13-2006, 4:42 PM
    • UK
    • Posts 96

    Was this resolved at all? I have a similar issue:

    Steps to Reproduce

    1) I have a DB table with a column which is varchar(1024)

    2) I want this column to only contain unique strings

    3) So I add a trigger to the column to check for the data entered and use RaisError if any problems

    4) I setup my Datagrid/ObjectDataSource/BLL/DAL and all works fine in aspx, the page errors with the correct message.

    5) I add in an AJAX Update Panel and *it* (the ASP.NET AJAX Libraries) just spits out a JSON string containing an alert message "An exception occured by the the target of an invocation". THAT is not the correct error string.

    Why is it not? and how do I alter this behaviour to make it send a JSON string containing the correct Error message?

    Thank you

  • Re: Exception has been thrown by the target of an invocation

    01-19-2009, 6:16 PM
    • Member
      38 point Member
    • Mustang65
    • Member since 01-10-2006, 1:21 PM
    • California
    • Posts 18

    Hi all,

     I know this is an old post but I do have an answer for it as I have run into the same situation just today.  The best way to handle this issue is to look for the error in the datasource updated event.

        Protected Sub ObjectDataSource1_Updated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.ObjectDataSourceStatusEventArgs) Handles ObjectDataSource1.Updated
            If Not IsNothing(e.Exception) Then
                msgbox( e.Exception.InnerException.ToString)
                e.ExceptionHandled = True

            End If
        End Sub

     

    This will trap the error and you should be able to see it at this point.  From what I have seen you must use the InnerException for the true error message.  The message portion of the exception only contains the generic error text.  I have been using this and it seems to work very well.

     

    Thanks,
    Mike L.
Page 1 of 1 (6 items)