Click here to Skip to main content
16,004,860 members
Home / Discussions / C#
   

C#

 
QuestionControl + Enter Pin
Rahul.RK24-May-07 23:49
Rahul.RK24-May-07 23:49 
AnswerRe: Control + Enter Pin
Martin#24-May-07 23:56
Martin#24-May-07 23:56 
GeneralRe: Control + Enter Pin
Rahul.RK25-May-07 0:34
Rahul.RK25-May-07 0:34 
Questionautomation Pin
s_khan_87624-May-07 23:29
s_khan_87624-May-07 23:29 
AnswerRe: automation Pin
blackjack215024-May-07 23:52
blackjack215024-May-07 23:52 
GeneralRe: automation Pin
s_khan_87627-May-07 3:08
s_khan_87627-May-07 3:08 
GeneralRe: automation Pin
blackjack215027-May-07 21:07
blackjack215027-May-07 21:07 
QuestionError handling in debug/run mode. Weird stuff. Pin
blackjack215024-May-07 23:16
blackjack215024-May-07 23:16 
The main method of a Windows Application:

static void Main(string[] args)<br />
        {<br />
            Application.EnableVisualStyles();<br />
            Application.SetCompatibleTextRenderingDefault(false);<br />
<br />
            try<br />
            {               <br />
                    Application.Run(new MainForm());               <br />
            }<br />
            catch (Exception ex)<br />
            {                <br />
                    MessageBox.Show("Caught exception in Main method.")<br />
            }<br />
        }


I've put the Run method inside a try-catch block.

When an exception is caught inside a method that belongs to the MainForm class, I throw that exception, expecting to see the MessageBox called from the Main method.

Things happen as expected when I run the program in debug mode form VS.

However, if I run the exe file directly from the Debug folder of my project, the program behaves differently, in the sense that the message box does not pop up anymore, and instead the much-hated "Unhandled exception has occured in your application." window shows.

The same happens if I generate a beep on the PC speaker(System.Console.Beep()) instead of showing the message box.

I really don't understand. Why is the exception caught only in Debug mode??

Thanks.
AnswerRe: Error handling in debug/run mode. Weird stuff. Pin
MicealG24-May-07 23:26
MicealG24-May-07 23:26 
GeneralRe: Error handling in debug/run mode. Weird stuff. Pin
Sandeep Akhare25-May-07 1:52
Sandeep Akhare25-May-07 1:52 
AnswerRe: Error handling in debug/run mode. Weird stuff. Pin
mav.northwind26-May-07 23:16
mav.northwind26-May-07 23:16 
GeneralRe: Error handling in debug/run mode. Weird stuff. Pin
blackjack215027-May-07 23:31
blackjack215027-May-07 23:31 
Questionreporting services Pin
kalyan_241624-May-07 23:08
kalyan_241624-May-07 23:08 
QuestionUnknown Dot Net Error Pin
MicealG24-May-07 23:05
MicealG24-May-07 23:05 
AnswerRe: Unknown Dot Net Error Pin
Muammar©24-May-07 23:13
Muammar©24-May-07 23:13 
GeneralRe: Unknown Dot Net Error Pin
MicealG24-May-07 23:25
MicealG24-May-07 23:25 
AnswerRe: Unknown Dot Net Error Pin
Guffa25-May-07 0:14
Guffa25-May-07 0:14 
GeneralRe: Unknown Dot Net Error Pin
MicealG25-May-07 2:26
MicealG25-May-07 2:26 
QuestionC# DataGridView using select statement need an example Pin
spawn_ro198524-May-07 22:51
spawn_ro198524-May-07 22:51 
AnswerRe: C# DataGridView using select statement need an example Pin
Muammar©24-May-07 23:17
Muammar©24-May-07 23:17 
GeneralRe: C# DataGridView using select statement need an example Pin
spawn_ro198525-May-07 5:29
spawn_ro198525-May-07 5:29 
Questionrunning .net application using Crystal Reports Pin
Seishin#24-May-07 22:32
Seishin#24-May-07 22:32 
AnswerRe: running .net application using Crystal Reports Pin
Harini N K24-May-07 23:33
Harini N K24-May-07 23:33 
GeneralRe: running .net application using Crystal Reports Pin
Seishin#29-May-07 23:49
Seishin#29-May-07 23:49 
QuestionAnimated gif in DataGridViewCell Pin
mertkan6524-May-07 22:31
mertkan6524-May-07 22:31 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.