Alright, so based on another question I asked about a program of mine not running, I'm trying to put this code into my program that will hopefully point out any unhandled exceptions to me. However, it's not working the way I've written it.
private void FileSort_Load(object sender, EventArgs e)
{
this.Size = new System.Drawing.Size(693, 603);
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Main_FormClosing);
System.AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
//insert here anything that will occur on the program's start
}
void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
{
throw new NotImplementedException();
// MessageBox.Show(e.ExceptionObject); //why doesn't this work?!?!?!?!?!?!?!?
}
So my issue is obviously with the Messagebox.Show() function in the code above. It tells me that it cannot convert from 'object' to 'string'. I tried using the ToString function, but that causes more problems...why won't this work the way it is? (I received this suggestion as an answer to my other question, but I'm not too familiar with this (as I'm new to C#, and OOP as a whole) so I'm not sure if I did anything wrong, I just let VS 2010 fill it in for me after typing System.AppDomain.CurrentDomain.UnhandledException +=)
Any help would be appreciated.