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?
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).
Marked as answer by JessyEzzy on Feb 02, 2007 08:30 PM
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.
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?
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?
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.
I have posted about a similar problem. Do you know if it is possible to pass the error up from the updated event to a central error handler? If so, what would the code in the Updated event look like?
JessyEzzy
Member
315 Points
102 Posts
Exception has been thrown by the target of an invocation
Feb 01, 2007 02:01 PM|LINK
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
michiel1978
Participant
1205 Points
250 Posts
Re: Exception has been thrown by the target of an invocation
Feb 02, 2007 12:26 PM|LINK
bobthecoder
Member
10 Points
5 Posts
Re: Exception has been thrown by the target of an invocation
Mar 06, 2007 02:33 AM|LINK
VR2
Member
134 Points
96 Posts
Re: Exception has been thrown by the target of an invocation
Mar 08, 2007 11:19 AM|LINK
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
VR2
Member
134 Points
96 Posts
Re: Exception has been thrown by the target of an invocation
Mar 08, 2007 11:19 AM|LINK
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
Mustang65
Member
46 Points
24 Posts
Re: Exception has been thrown by the target of an invocation
Jan 19, 2009 10:16 PM|LINK
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.
Mike L.
Vivani
Member
6 Points
25 Posts
Re: Exception has been thrown by the target of an invocation
Feb 05, 2010 12:03 PM|LINK
I have posted about a similar problem. Do you know if it is possible to pass the error up from the updated event to a central error handler? If so, what would the code in the Updated event look like?