Note that there are some explanatory texts on larger screens.

plurals
  1. POC# Desktop Application "Encounters an error and has to exit" on first run of the day
    primarykey
    data
    text
    <p>It seems I tend to attract strange issues. This time, I have written a C# application, and handled most of the exceptions I can find. The problem is, when I run the installed/bundled version on any PC for the first time in a day (after the PC has been shut down and started after a while) it comes across some error and has to shutdown the application (even though the try-catch block surrounding the Main() does not fire). The application does not throw the same error on subsequent runs.</p> <pre><code>static class Program { /// &lt;summary&gt; /// The main entry point for the application. /// &lt;/summary&gt; [STAThread] static void Main() { // your event handler Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException); // your event handler AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); // you try catch block and Application.Run try { #if(!DEBUG) Application.EnableVisualStyles(); Application.Run(new newTerminal()); #else Application.EnableVisualStyles(); newTerminal terminal = new newTerminal(); terminal.ShowDialog(); #endif } catch (Exception ex) { MessageBox.Show("There was an error loading the modules. Please restart the application.", "Oops!"); //return; CreateLogFiles.ErrorLog("Error: " + ex.Message); throw ex; } } static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) { MessageBox.Show("There was an error loading the modules. Please restart the application.", "Oops!"); Application.Exit(); } static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e) { MessageBox.Show("There was an error loading the modules. Please restart the application.", "Oops!"); Application.Exit(); } } </code></pre> <p>There's the full code in Main().Any help is appreciated. I'm running out of time, and getting a bit desparate. Thanks in advance!</p>
    singulars
    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.
    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