G
Guinness Mann
Pardon me if this is not the optimum newsgroup for this post, but it's
the only .NET newsgroup I read and I'm certain someone here can help me.
I have a C# program that checks for an error condition and if it finds
it it notifies the user with a MessageBox and then on the next line of
code (example in a minute) it calls Application.Exit().
To my astonishment, I stepped through the code with the debugger, and
watched it call Application.Exit() and then proceed to the next
statement.
Here's the code:
string s = "Some error message..."
if (!lNames.isValidLanguage(ref strLanguage))
{
MessageBox.Show (s, "AppName", MessageBoxButtons.OK,
MessageBoxIcon.Exclamation );
Application.Exit();
}
As I mentioned, I stepped through the code and even stepped through it
in disassembly mode to make sure the Exit function was actually being
called.
My workaround is to replace Application.Exit() with:
throw new System.Exception();
And then catch it in Main, and call Application.Exit() there.
[STAThread]
static void Main()
{
try
{
Application.Run(new frmITQ());
}
catch
{
Application.Exit();
}
}
Does anyone have a clue for me? (Yes, I know I should make a custom
exception and test specifically for it, but this is just a
troubleshooting technique and I haven't completely given up on
Application.Exit() yet.)
-- Rick
the only .NET newsgroup I read and I'm certain someone here can help me.
I have a C# program that checks for an error condition and if it finds
it it notifies the user with a MessageBox and then on the next line of
code (example in a minute) it calls Application.Exit().
To my astonishment, I stepped through the code with the debugger, and
watched it call Application.Exit() and then proceed to the next
statement.
Here's the code:
string s = "Some error message..."
if (!lNames.isValidLanguage(ref strLanguage))
{
MessageBox.Show (s, "AppName", MessageBoxButtons.OK,
MessageBoxIcon.Exclamation );
Application.Exit();
}
As I mentioned, I stepped through the code and even stepped through it
in disassembly mode to make sure the Exit function was actually being
called.
My workaround is to replace Application.Exit() with:
throw new System.Exception();
And then catch it in Main, and call Application.Exit() there.
[STAThread]
static void Main()
{
try
{
Application.Run(new frmITQ());
}
catch
{
Application.Exit();
}
}
Does anyone have a clue for me? (Yes, I know I should make a custom
exception and test specifically for it, but this is just a
troubleshooting technique and I haven't completely given up on
Application.Exit() yet.)
-- Rick