CSharp Custom Exception
-
Hi Guys! we know that there is a way to handle custom exceptions in asp dot net by specify the error page. is there any way to do the same in csharp windows form. i.e custom windows form. i don't want to write try/catch block in my programm in all places.i just want to write it once where it can handle all the program exception. is there a way.:(( Ali Khan
-
Hi Guys! we know that there is a way to handle custom exceptions in asp dot net by specify the error page. is there any way to do the same in csharp windows form. i.e custom windows form. i don't want to write try/catch block in my programm in all places.i just want to write it once where it can handle all the program exception. is there a way.:(( Ali Khan
-
Legend Never Dies wrote: is there any way to do the same in csharp windows form. No. You can't get exceptions without try/catch,I think the best you can do is use try/catch and popup your custom error form in catch part. Mazy No sig. available now.
No u don't understand my question, i want to write only one try/catch block that can handle all the exceptions of the whole applications, which off-course may contains multiple windows forms
-
Hi Guys! we know that there is a way to handle custom exceptions in asp dot net by specify the error page. is there any way to do the same in csharp windows form. i.e custom windows form. i don't want to write try/catch block in my programm in all places.i just want to write it once where it can handle all the program exception. is there a way.:(( Ali Khan
Handle the
HttpApplication.Error
event in your Global.asax file, or it's related code-behind file. Since auto-event-writeup is enabled by default, you can just declare your handler asprivate void Application_Error(object sender, EventArgs e)
{
HttpServerUtility server = HttpContext.Current.Server
Exception e = server.GetLastError();
// ...
}For more information, see the documentation for the event I mentioned, and the
HttpServerUtility.GetLastError
method. You could also create your ownIHttpModule
for handling, errors, too, if you require library portability without moving the whole web application.-----BEGIN GEEK CODE BLOCK----- Version: 3.21 GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++ -----END GEEK CODE BLOCK-----