Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / October 2006

Tip: Looking for answers? Try searching our database.

Global Error Handler

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
yeghia (sosy) - 10 Oct 2006 21:55 GMT
Hi Guys

I have two questions.
1. Is there a way to set a handler to .NET application so that in case of
not caught exception my handler is called before application shutdown. I
want to send an email from this handler with details of error.
2. Is there a way to capture the text (with stack frame etc) displayed in a
dialog which is shown when unhandled execption is thrown

Thanks in advance for your help

Regards
Yeghia
JP - 10 Oct 2006 22:13 GMT
All your uncaught errors go though the Global.asax file

 void Application_Error(object sender, EventArgs e)
{
    errors ApplicationError = new errors();
    ApplicationError.LogApplicationError(Error.GetType().ToString(),Request.Path.ToString(),
Request.Url.ToString(), Error.Source.ToString(), Error.Message.ToString(),
Error.StackTrace.ToString(), Error.TargetSite.ToString());
    Server.ClearError();
    ApplicationError.Dispose();
    Server.Transfer("error.aspx?Message=" + Error.GetType().ToString(), false);

}

Here you can process that error how you see fit. We try to write our
unhandled errors to an SQL log table. If this fails, we contact to SMTP and
see the error report directly to the programmer.  The parameter list above is
the more common items you can return.

Signature

JP
.NET Software Developer

> Hi Guys
>
[quoted text clipped - 9 lines]
> Regards
> Yeghia
Scott M. - 10 Oct 2006 22:54 GMT
That's *if* you are talking about an ASP.NET web applicationa.  The OP
didn't specify.

> All your uncaught errors go though the Global.asax file
>
[quoted text clipped - 32 lines]
>> Regards
>> Yeghia
burettethomas@gmail.com - 11 Oct 2006 13:06 GMT
Yes it is possible, look over here for some examples on how to have an
handler catch all the unhandled exceptions :
http://www.codeproject.com/dotnet/unhandledexceptions.asp
http://www.codeproject.com/dotnet/ExceptionHandling.asp
http://www.codeproject.com/dotnet/SafeForm.asp

However be careful of a few things :
-behaviour might differ if you run your program with or without the
debugger
-behaviour might differ if you have visual studio installed or not on
the computer
-Make sure that it works with different forms (some people seems to
have problems : unhandled exceptions of one form are catch and
exceptions from another form are not)

yeghia (sosy) schreef:

> Hi Guys
>
[quoted text clipped - 9 lines]
> Regards
> Yeghia

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.