如何知道进程崩溃了 [英] How to know that Process has crashed

查看:134
本文介绍了如何知道进程崩溃了的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的控制台应用程序中,我有一个代码看起来像

  Process DKU = new Process 
DKU.StartInfo.FileName =MSSQLExecutor.exe;
DKU.Start();
DKU.WaitForExit();
Console.WriteLine(let move on);

这是工作正常,它等待,直到MSSQLExecutor.exe完成其工作,然后
。应用程序继续。



我的问题是有时MSSQLExecutor.exe崩溃,Windows默认情况下显示一个结束程序的对话框。在这一点上,我的应用程序将永远等待用户单击关闭按钮。



我想避免这种情况,因为我的应用程序将作为一个服务运行,而无需用户交互。



img src =https://i.stack.imgur.com/khkHw.jpgalt =之后我想移动白我的应用程序>

$ c> MSSQLExecutor 是您的应用程序,您应该解决这个问题。
但是你可以达到目标(隐藏对话框)。处理 Application.ThreadException AppDomain.CurrentDomain.UnhandledException

  Application.ThreadException + = new System.Threading.ThreadExceptionEventHandler(Application_ThreadException); 
AppDomain.CurrentDomain.UnhandledException + = new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);


static void CurrentDomain_UnhandledException(object sender,UnhandledExceptionEventArgs e)
{
//记录异常
}

static void Application_ThreadException(object sender,System.Threading.ThreadExceptionEventArgs e)
{
//记录异常
}


  • 如果 MSSQLExecutor 不是您的应用程式,可以停用Dr. Watson


    Dr。





    • 单击开始,单击运行,键入regedit.exe在打开框中,然后单击确定。

    • 找到并单击下面的注册表项:

      HKEY_LOCAL_MACHINE \Software \Microsoft\Windows NT \CurrentVersion\AeDebug

    • 单击AeDebug密钥,然后单击注册表菜单上的导出注册表文件。

    • 删除AeDebug密钥。




  • 更多信息




    In my console application I have code which looks like

        Process DKU = new Process();
        DKU.StartInfo.FileName = "MSSQLExecutor.exe";
        DKU.Start();
        DKU.WaitForExit();
        Console.WriteLine("lets move on ");
    

    This is working fine and it waits until MSSQLExecutor.exe finishes its job, then after that the app continues.

    My problem is that sometimes MSSQLExecutor.exe crashes and Windows by default shows a dialog for ending the program. At that point my application will wait forever for the user to click the Close button.

    I want to avoid this because MY application is going to run as a service without user interaction.

    解决方案

    The Dialog prevents that the process exists.

    1. If MSSQLExecutor is your Application you should fix the problem. But you can reach the goal (hiding the Dialog). Handle Application.ThreadException and AppDomain.CurrentDomain.UnhandledException

      Application.ThreadException +=new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);
      AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
      
      
      static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
      {
          // log the exception
      }
      
      static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e)
      {
          // log the exception
      }
      

    2. If MSSQLExecutor is not your Application you can deactivate Dr. Watson

      Dr. Watson is an application debugger included with the Microsoft Windows operating system.

      • Click Start, click Run, type regedit.exe in the Open box, and then click OK.
      • Locate and then click the following registry key:
        HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\AeDebug
      • Click the AeDebug key, and then click Export Registry File on the Registry menu.
      • Delete the AeDebug key.

    More Infromation

    这篇关于如何知道进程崩溃了的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆