我的exe已经崩溃了 [英] My exe has crashed

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

问题描述

大家好,


我们创建一个媒体播放器exe。经过一段时间玩家玩,然后给出以下错误。为什么Windows抛出此错误以及如何解决此错误"媒体播放器已停止工作"。

解决方案


1。我们可以在VS或相关IDE中调试此问题。并执行相同的步骤来重现此问题。它将抛出相关的例外情况。


2。更好的做法。写日志申请。这是一个好习惯。当我们发布我们的产品时,我们无法调试客户机器上的异常/错误。但我们可以收集相关的异常/错误日志。它将帮助我们缩小问题的范围。


在我看来,这个应用程序因未处理的异常而崩溃。以下是我对此方案的建议。


1)。如果它是Windows窗体应用程序,我们可以处理这样的未处理异常,

 public static void Main(string [] args)
{
//添加用于处理事件的UI线程异常的事件处理程序。
Application.ThreadException + = new
ThreadExceptionEventHandler(ErrorHandlerForm.Form1_UIThreadException);

//设置未处理的异常模式以强制所有Windows窗体错误
//通过我们的处理程序。
Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);

//添加用于处理事件的非UI线程异常的事件处理程序。
AppDomain.CurrentDomain.UnhandledException + = new
UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
}

请在此处查看示例,
http://msdn.microsoft.com/en-us/library/system.windows.forms.application .threadexception.aspx


2)。如果是WPF应用程序,我们可以处理这样的未处理异常,

 AppDomain.CurrentDomain.UnhandledException + = 
new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException) );

有关详细信息,请参阅:
http://msdn.microsoft.com/en-us/library/system.windows.application.dispatcherunhandledexception.aspx


3)。如果是C ++应用程序,请参阅: http://msdn.microsoft.com/en -us / library / ac9f67ah.aspx


祝你玩得愉快!


<跨度>此致


Hi all,

We create a media player exe. After some time player has play then give the below error.Why this error thrown by windows and how to solve this error "Media Player has stopped working".

解决方案

Hi,

1. We can debug this issue in VS or related IDE. And perform the same steps to reproduce this issue. It will throw the relevant exceptions.

2. A better practice. Write log for application. It’s a good habit. When we released our products, we cannot debug the exceptions/errors on clients’ machine. But we can collect the relevant exception/error logs. It will help us to narrow down the issue.

In my view, this application crashed by unhandled exception. Here are my suggestions for this scenario.

1). If it is a Windows Forms Application, we can handle unhandled exception like this,

public static void Main(string[] args)
{
   // Add the event handler for handling UI thread exceptions to the event.
    Application.ThreadException += new     
  ThreadExceptionEventHandler(ErrorHandlerForm.Form1_UIThreadException);

  // Set the unhandled exception mode to force all Windows Forms errors
  // to go through our handler.
  Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);

  // Add the event handler for handling non-UI thread exceptions to the event. 
  AppDomain.CurrentDomain.UnhandledException += new       
  UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
}

Please take a look at the sample here, http://msdn.microsoft.com/en-us/library/system.windows.forms.application.threadexception.aspx

2). If it is a WPF application, we can handle unhandled exception like this,

AppDomain.CurrentDomain.UnhandledException += 
        new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);

For more information, see: http://msdn.microsoft.com/en-us/library/system.windows.application.dispatcherunhandledexception.aspx

3). If it is a C++ application, see: http://msdn.microsoft.com/en-us/library/ac9f67ah.aspx

Have a nice time!

Sincerely,


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

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