B
bg_ie
Hi,
I have the following Program.cs -
namespace TestFrameworkApplication
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.ThreadException += new
ThreadExceptionEventHandler(new
ThreadExceptionHandler().ApplicationThreadException);
Application.Run(new FormMain());
}
/// <summary>
/// Handles any thread exceptions
/// </summary>
public class ThreadExceptionHandler
{
public void ApplicationThreadException(object sender,
ThreadExceptionEventArgs e)
{
MessageBox.Show(e.Exception.Message, "An exception
occurred:", MessageBoxButtons.OK, MessageBoxIcon.Error);
Application.Exit();
}
}
}
}
In my Form, I attempt the following -
private void button1_Click(object sender, EventArgs e)
{
ThrowException();
}
private void ThrowException()
{
throw new ApplicationException("Monkey exception");
}
But when I click on the corresponding button, I keep getting the
message "ApplicationException unhandled by user code" from the
debugger. But once I continue the debugger, the message box pops up
with the error. What is the debugger warning me about and can I switch
off this message if I am not actually doing anything incorrect?
Thanks for your help,
Barry.
I have the following Program.cs -
namespace TestFrameworkApplication
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.ThreadException += new
ThreadExceptionEventHandler(new
ThreadExceptionHandler().ApplicationThreadException);
Application.Run(new FormMain());
}
/// <summary>
/// Handles any thread exceptions
/// </summary>
public class ThreadExceptionHandler
{
public void ApplicationThreadException(object sender,
ThreadExceptionEventArgs e)
{
MessageBox.Show(e.Exception.Message, "An exception
occurred:", MessageBoxButtons.OK, MessageBoxIcon.Error);
Application.Exit();
}
}
}
}
In my Form, I attempt the following -
private void button1_Click(object sender, EventArgs e)
{
ThrowException();
}
private void ThrowException()
{
throw new ApplicationException("Monkey exception");
}
But when I click on the corresponding button, I keep getting the
message "ApplicationException unhandled by user code" from the
debugger. But once I continue the debugger, the message box pops up
with the error. What is the debugger warning me about and can I switch
off this message if I am not actually doing anything incorrect?
Thanks for your help,
Barry.