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. .NET (Core and Framework)
  4. Exception handling....

Exception handling....

Scheduled Pinned Locked Moved .NET (Core and Framework)
csharpquestionhelp
3 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.
  • C Offline
    C Offline
    CherezZaboro
    wrote on last edited by
    #1

    Excuse me for a quick noob question: Let's say a component of my C# application throws and exception. I want to catch it and handle it, but! I have try...catch in program.cs around the whole Application.Run(new FormMain()); and yet the system itself somehow pops the "application error" dialog with the whole backtrace and all. I'm guessing it's catching the exception sooner somewhere handling my FormMain execution. Where would I then place the whole form wide exception handling to intercept it before the .NET code? 3.1415

    J N 2 Replies Last reply
    0
    • C CherezZaboro

      Excuse me for a quick noob question: Let's say a component of my C# application throws and exception. I want to catch it and handle it, but! I have try...catch in program.cs around the whole Application.Run(new FormMain()); and yet the system itself somehow pops the "application error" dialog with the whole backtrace and all. I'm guessing it's catching the exception sooner somewhere handling my FormMain execution. Where would I then place the whole form wide exception handling to intercept it before the .NET code? 3.1415

      J Offline
      J Offline
      Jun Du
      wrote on last edited by
      #2

      I might be missing something, but it sounds like .NET can catch the exception raised in your code before you can. If you don't know where exactly the exception could be raised, you needn't do anything. If you do know the exact code segment, try to catch and handle the exception before .NET does.

      Best, Jun

      1 Reply Last reply
      0
      • C CherezZaboro

        Excuse me for a quick noob question: Let's say a component of my C# application throws and exception. I want to catch it and handle it, but! I have try...catch in program.cs around the whole Application.Run(new FormMain()); and yet the system itself somehow pops the "application error" dialog with the whole backtrace and all. I'm guessing it's catching the exception sooner somewhere handling my FormMain execution. Where would I then place the whole form wide exception handling to intercept it before the .NET code? 3.1415

        N Offline
        N Offline
        Not Active
        wrote on last edited by
        #3

        Try handling the AppDomain.UnhandledException event. However, you should find the cause of the exception and handle it at the point closest to where it is being thrown


        only two letters away from being an asset

        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