未处理的异常不会被处理程序捕获 [英] Unhandled exception is not being caught by the handlers

查看:144
本文介绍了未处理的异常不会被处理程序捕获的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们已经通过以下方式注册了未处理的异常.该应用程序是远程服务器.如果从远程服务器抛出未处理的异常,则未处理的异常处理程序不会处理该异常.可能是什么问题?

We have registered for the unhandled exceptions in the following way. The application is a remoting server. If an unhandled exception is thrown from the remoting server it is not handled by the unhandled exception handlers. What could be the problem?

[STAThread]

[Obfuscation(Exclude = true)]
static void Main(string[] args)
{

    Application.ThreadException += new ThreadExceptionEventHandler(OnThreadException);
    AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(OnUnhandledException);
    .
    .
    .

    Application.EnableVisualStyles();
    Application.Run(form);

}

推荐答案

希望此方法可以帮助您

Hope this method helps you 'Application.SetUnhandledExceptionMode'. It instructs the application how to respond to unhandled exceptions.

static void Main(string[] args)
{

    Application.ThreadException += new ThreadExceptionEventHandler(OnThreadException);
    AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(OnUnhandledException);

    Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);

    Application.EnableVisualStyles();
    Application.Run(form);

}

这篇关于未处理的异常不会被处理程序捕获的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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