none
Application stop working! RRS feed

  • Question

  • Yesterday I created winform  exe using c# and installed in windows 8.1Pc . It works fine. But now,  If I launching the exe, There is an error stopped working. Now I am not able to launch the exe. Please any one suggest me.  
    Monday, March 14, 2016 4:23 AM

Answers

  • Hi Gred,

    >>Now I am not able to launch the exe. Please any one suggest me.  

    I would suggest you use the following code, to determine that is the error you need to catch all unhandled exceptions, to do this, add the handler of unhandled exceptions in the main method of your application.

    static void Main()
    {
      Application.EnableVisualStyles();
      Application.SetCompatibleTextRenderingDefault(false);
    
      Application.ThreadException += new ThreadExceptionEventHandler(Application_ThreadException);
      AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
    
      Application.Run(new Form1());
    }
    
    static void Application_ThreadException(object sender, ThreadExceptionEventArgs e)
    {
      MessageBox.Show(e.Exception.Message, "Unhandled Thread Exception");
      // here you can log the exception ...
    }
    
    static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
    {
      MessageBox.Show((e.ExceptionObject as Exception).Message, "Unhandled UI Exception");
      // here you can log the exception ...
    }

    Please also refer to https://msdn.microsoft.com/en-us/library/system.windows.forms.application.threadexception(v=vs.110).aspx for more details.

    Note the Examples section.

    Best regards,

    Kristin


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, March 14, 2016 5:20 AM

All replies

  • Hi Gred,

    >>Now I am not able to launch the exe. Please any one suggest me.  

    I would suggest you use the following code, to determine that is the error you need to catch all unhandled exceptions, to do this, add the handler of unhandled exceptions in the main method of your application.

    static void Main()
    {
      Application.EnableVisualStyles();
      Application.SetCompatibleTextRenderingDefault(false);
    
      Application.ThreadException += new ThreadExceptionEventHandler(Application_ThreadException);
      AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
    
      Application.Run(new Form1());
    }
    
    static void Application_ThreadException(object sender, ThreadExceptionEventArgs e)
    {
      MessageBox.Show(e.Exception.Message, "Unhandled Thread Exception");
      // here you can log the exception ...
    }
    
    static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
    {
      MessageBox.Show((e.ExceptionObject as Exception).Message, "Unhandled UI Exception");
      // here you can log the exception ...
    }

    Please also refer to https://msdn.microsoft.com/en-us/library/system.windows.forms.application.threadexception(v=vs.110).aspx for more details.

    Note the Examples section.

    Best regards,

    Kristin


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, March 14, 2016 5:20 AM
  • Thanks, it works fine now!
    Tuesday, March 15, 2016 10:00 AM