Hi, I'm working with visual studio 2005, visual basic .net and I'm trying to use the Page_Error method to catch unhandled exceptions in my code. I want to catch errors during callbacks, is there something about the way callbacks are handled that prevents the Page_Error method from being called because no matter what I do I don't seem to be able to get it to fire.
The sequence of events is:
RaiseCallbackEvent calls a function with an error in it (Throw New ArgumentNullException("error"))
At this point I expect Page_Error to be raised, but the code immediately calls GetCallbackResult.
I have autoeventwireup = "false" in my page but I'm using Private Sub Page_Error(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Error. I thought that using Handles means you don't need autoeventwireup set to true.
Adding the Addhandler to the Page_Load Event on my page.
Setting autoeventwireup = "true"
Changing the Handles Me.Error to MyBase.Error (I read somewhere that that would fix it)
All to no avail. I appreciate anyone who can shed some light on this subject for me.
Edit: I've done some more testing and found that the Page_Error works just as I would expect if I'm NOT in a callback. If I place the fake error in the page load event the Page_Error event does fire. This makes me believe that everything is wired up correctly, I suppose I'm just not using the correct method for catching errors during a callback.