C# conversion error
<p>I get the following error from the code shown below and can not find a way to cast the object properly. Any help greatly appreciated.</p>

<p>The error occurs on the ex = e.ExceptionObject; line.</p>

<blockquote>
  <p>Cannot implicitly convert type 'object' to 'System.Exception'. An
  explicit conversion exists (are you missing a cast?) (CS0266) -
  C:\DocmentMDB\DocumentMDB.ConvertedToC#\ErrorHandler.cs:59,9</p>
</blockquote>

<pre><code>public static void UnhandledExceptionHandler(object sender, UnhandledExceptionEventArgs e)
{
    // handles all unhandled (i.e. no Catch block) exceptions
    // the following code must be placed in Sub Main and the project
    // use Sub Main as startup
    //Dim currentDomain As AppDomain = AppDomain.CurrentDomain
    //AddHandler currentDomain.UnhandledException, AddressOf myExceptionHandler

    Exception ex = null;
    ex = e.ExceptionObject;

    string strErrorMsg = null;
    string strDisplayMsg = null;
    string strPrintMsg = null;
    int intLoc = 0;

    strErrorMsg = "Unhandled Error In : " + strFormName + " - " + ex.TargetSite.Name + Constants.vbCrLf + Constants.vbCrLf + ex.Message;

    strPrintMsg = "Error detected: " + DateAndTime.Now + Constants.vbCrLf + Constants.vbCrLf + strErrorMsg + Constants.vbCrLf + Constants.vbCrLf + ex.StackTrace;

    strDisplayMsg = "Report this error to your System Administrator" + Constants.vbCrLf + Constants.vbCrLf + strErrorMsg + Constants.vbCrLf + Constants.vbCrLf + "Click YES to print this message.";

    if (MessageBox.Show(strDisplayMsg, "Unhandled Program Error", MessageBoxButtons.YesNo) == DialogResult.Yes) {
        // print the error message
        ErrPrint myPrintObject = new ErrPrint(strPrintMsg);
        myPrintObject.Print();
    }
}
</code></pre>
