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. Release versus Debug exception catching?

Release versus Debug exception catching?

Scheduled Pinned Locked Moved C#
csharphelpannouncementworkspacealgorithms
5 Posts 4 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.
  • T Offline
    T Offline
    theFrenchHornet
    wrote on last edited by
    #1

    Is there a known problem with the release version of the C# .NET 2003 compiler as regards exception catching? Can someone point me to where Microsoft lists all known bugs? I have been searching and haven't turned it up. I found a page which listed bugs fixed in a particular release, but haven't found anything about this. I am trying, at the top level of an application, to catch any errors which have bubbled up from below. I have a try/catch around the Application.Run that brings up the main form of an application. This is in one project. The form is in a different project. If I build in debug mode and an error occurs on the form, the error is caught by my application. If I build in release mode, the error is not caught by may application - a message box comes up showing the error was caught by the system. I created a sample solution to simplify the environment and the problem still occurs. My concern is not with the particular error which is getting by my catch, but with the fact that any error is. Is there something inherently wrong with the way I am doing it, and it just happens to work in Debug configuration, or is there a problem with the release compiler?

    Here is the code I used to demonstrate the problem:

    From the project 'starter':

    using System; using System.Windows.Forms; using FormPart; namespace starter { public class starter { [STAThread] static void Main() { try { Application.Run(new FormFormPart()); } catch (Exception e) { MessageBox.Show("Exception Caught", "starter Message"); } } } }
    From the project FormPart in the namespace FormPart which has a populated DataGrid object:
    private void button1_Click(object sender, System.EventArgs e) { dataView2.RowFilter = "Distance Like 'a'"; }

    The error occurs because Distance is defined as a System.Double column. Again, I'm not concerned about fixing this particular error - just about how any error is getting by the catch at the top level. Thanks for any thoughts ...

    S M T 3 Replies Last reply
    0
    • T theFrenchHornet

      Is there a known problem with the release version of the C# .NET 2003 compiler as regards exception catching? Can someone point me to where Microsoft lists all known bugs? I have been searching and haven't turned it up. I found a page which listed bugs fixed in a particular release, but haven't found anything about this. I am trying, at the top level of an application, to catch any errors which have bubbled up from below. I have a try/catch around the Application.Run that brings up the main form of an application. This is in one project. The form is in a different project. If I build in debug mode and an error occurs on the form, the error is caught by my application. If I build in release mode, the error is not caught by may application - a message box comes up showing the error was caught by the system. I created a sample solution to simplify the environment and the problem still occurs. My concern is not with the particular error which is getting by my catch, but with the fact that any error is. Is there something inherently wrong with the way I am doing it, and it just happens to work in Debug configuration, or is there a problem with the release compiler?

      Here is the code I used to demonstrate the problem:

      From the project 'starter':

      using System; using System.Windows.Forms; using FormPart; namespace starter { public class starter { [STAThread] static void Main() { try { Application.Run(new FormFormPart()); } catch (Exception e) { MessageBox.Show("Exception Caught", "starter Message"); } } } }
      From the project FormPart in the namespace FormPart which has a populated DataGrid object:
      private void button1_Click(object sender, System.EventArgs e) { dataView2.RowFilter = "Distance Like 'a'"; }

      The error occurs because Distance is defined as a System.Double column. Again, I'm not concerned about fixing this particular error - just about how any error is getting by the catch at the top level. Thanks for any thoughts ...

      S Offline
      S Offline
      Stefan Troschuetz
      wrote on last edited by
      #2

      Application.ThreadException event[^]


      www.troschuetz.de

      1 Reply Last reply
      0
      • T theFrenchHornet

        Is there a known problem with the release version of the C# .NET 2003 compiler as regards exception catching? Can someone point me to where Microsoft lists all known bugs? I have been searching and haven't turned it up. I found a page which listed bugs fixed in a particular release, but haven't found anything about this. I am trying, at the top level of an application, to catch any errors which have bubbled up from below. I have a try/catch around the Application.Run that brings up the main form of an application. This is in one project. The form is in a different project. If I build in debug mode and an error occurs on the form, the error is caught by my application. If I build in release mode, the error is not caught by may application - a message box comes up showing the error was caught by the system. I created a sample solution to simplify the environment and the problem still occurs. My concern is not with the particular error which is getting by my catch, but with the fact that any error is. Is there something inherently wrong with the way I am doing it, and it just happens to work in Debug configuration, or is there a problem with the release compiler?

        Here is the code I used to demonstrate the problem:

        From the project 'starter':

        using System; using System.Windows.Forms; using FormPart; namespace starter { public class starter { [STAThread] static void Main() { try { Application.Run(new FormFormPart()); } catch (Exception e) { MessageBox.Show("Exception Caught", "starter Message"); } } } }
        From the project FormPart in the namespace FormPart which has a populated DataGrid object:
        private void button1_Click(object sender, System.EventArgs e) { dataView2.RowFilter = "Distance Like 'a'"; }

        The error occurs because Distance is defined as a System.Double column. Again, I'm not concerned about fixing this particular error - just about how any error is getting by the catch at the top level. Thanks for any thoughts ...

        M Offline
        M Offline
        mav northwind
        wrote on last edited by
        #3

        Hi! Yes, this is a known (although not too well-known) behaviour. Until now I couldn't get a plausible explanation why this behaviour occurrs, but at least there's a workaround. Take a look at this discussion[^] on the same topic. Regards, mav

        D 1 Reply Last reply
        0
        • M mav northwind

          Hi! Yes, this is a known (although not too well-known) behaviour. Until now I couldn't get a plausible explanation why this behaviour occurrs, but at least there's a workaround. Take a look at this discussion[^] on the same topic. Regards, mav

          D Offline
          D Offline
          Daniel Grunwald
          wrote on last edited by
          #4

          The reason is quite simple: Windows.Forms has it's own error dialog that allows to choose "continue" if an error occured inside an event handler. Then the form tries to continue execution. But if you're running with a debugger attached, Windows.Forms does not use it's error dialog to give the debugger (or another try-catch statement) a chance to handle the exception. To catch all exceptions in all cases, you have to: - create a global try-catch in your Main method - handle the Application.ThreadException event (for exceptions in Windows.Forms) - handle the AppDomain.CurrentDomain.UnhandledException event (for exceptions in other threads)

          1 Reply Last reply
          0
          • T theFrenchHornet

            Is there a known problem with the release version of the C# .NET 2003 compiler as regards exception catching? Can someone point me to where Microsoft lists all known bugs? I have been searching and haven't turned it up. I found a page which listed bugs fixed in a particular release, but haven't found anything about this. I am trying, at the top level of an application, to catch any errors which have bubbled up from below. I have a try/catch around the Application.Run that brings up the main form of an application. This is in one project. The form is in a different project. If I build in debug mode and an error occurs on the form, the error is caught by my application. If I build in release mode, the error is not caught by may application - a message box comes up showing the error was caught by the system. I created a sample solution to simplify the environment and the problem still occurs. My concern is not with the particular error which is getting by my catch, but with the fact that any error is. Is there something inherently wrong with the way I am doing it, and it just happens to work in Debug configuration, or is there a problem with the release compiler?

            Here is the code I used to demonstrate the problem:

            From the project 'starter':

            using System; using System.Windows.Forms; using FormPart; namespace starter { public class starter { [STAThread] static void Main() { try { Application.Run(new FormFormPart()); } catch (Exception e) { MessageBox.Show("Exception Caught", "starter Message"); } } } }
            From the project FormPart in the namespace FormPart which has a populated DataGrid object:
            private void button1_Click(object sender, System.EventArgs e) { dataView2.RowFilter = "Distance Like 'a'"; }

            The error occurs because Distance is defined as a System.Double column. Again, I'm not concerned about fixing this particular error - just about how any error is getting by the catch at the top level. Thanks for any thoughts ...

            T Offline
            T Offline
            theFrenchHornet
            wrote on last edited by
            #5

            Thanks - working now. All 3 responses were helpful.

            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