Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. CSharp Custom Exception

CSharp Custom Exception

Scheduled Pinned Locked Moved C#
csharphelp
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • U Offline
    U Offline
    User 334793
    wrote on last edited by
    #1

    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

    M H 2 Replies Last reply
    0
    • U User 334793

      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

      M Offline
      M Offline
      Mazdak
      wrote on last edited by
      #2

      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.

      U 1 Reply Last reply
      0
      • M Mazdak

        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.

        U Offline
        U Offline
        User 334793
        wrote on last edited by
        #3

        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

        1 Reply Last reply
        0
        • U User 334793

          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

          H Offline
          H Offline
          Heath Stewart
          wrote on last edited by
          #4

          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 as

          private 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 own IHttpModule 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-----

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups