Hi,
I have the following Program.cs -
namespace TestFrameworkAp plication
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Ena bleVisualStyles ();
Application.Set CompatibleTextR enderingDefault (false);
Application.Thr eadException += new
ThreadException EventHandler(ne w
ThreadException Handler().Appli cationThreadExc eption);
Application.Run (new FormMain());
}
/// <summary>
/// Handles any thread exceptions
/// </summary>
public class ThreadException Handler
{
public void ApplicationThre adException(obj ect sender,
ThreadException EventArgs e)
{
MessageBox.Show (e.Exception.Me ssage, "An exception
occurred:", MessageBoxButto ns.OK, MessageBoxIcon. Error);
Application.Exi t();
}
}
}
}
In my Form, I attempt the following -
private void button1_Click(o bject sender, EventArgs e)
{
ThrowException( );
}
private void ThrowException( )
{
throw new ApplicationExce ption("Monkey exception");
}
But when I click on the corresponding button, I keep getting the
message "ApplicationExc eption 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 TestFrameworkAp plication
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Ena bleVisualStyles ();
Application.Set CompatibleTextR enderingDefault (false);
Application.Thr eadException += new
ThreadException EventHandler(ne w
ThreadException Handler().Appli cationThreadExc eption);
Application.Run (new FormMain());
}
/// <summary>
/// Handles any thread exceptions
/// </summary>
public class ThreadException Handler
{
public void ApplicationThre adException(obj ect sender,
ThreadException EventArgs e)
{
MessageBox.Show (e.Exception.Me ssage, "An exception
occurred:", MessageBoxButto ns.OK, MessageBoxIcon. Error);
Application.Exi t();
}
}
}
}
In my Form, I attempt the following -
private void button1_Click(o bject sender, EventArgs e)
{
ThrowException( );
}
private void ThrowException( )
{
throw new ApplicationExce ption("Monkey exception");
}
But when I click on the corresponding button, I keep getting the
message "ApplicationExc eption 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.
Comment