Note that there are some explanatory texts on larger screens.

plurals
  1. POC# conversion error
    primarykey
    data
    text
    <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>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload