我正在尝试创建一个AppDomain,并从F#附加到它的UnhandledException事件,但我没有多少运气。在我的事件处理程序中,我需要对触发事件的域以及事件参数的引用。
若要重现此问题,必须在已编译的应用程序中运行以下代码。在F#互动中运行它会产生另一个可能与之无关的错误。
open System
open System.Reflection
let domainError (domain:AppDomain) (args:UnhandledExceptionEventArgs) =
()
let domain = AppDomain.CreateDomain("
我决定对我的一个应用程序启用严格的选项。在我的一生中,我不知道如何做一点代码编译。在一个模块中,我有一段代码
Sub Main()
AddHandler AppDomain.CurrentDomain.UnhandledException, AddressOf CurrentDomain_UnhandledException
End Sub
Private Sub CurrentDomain_UnhandledException(sender As Object, e As UnhandledExceptionEventArgs)
e.E
据我所知,我完全遵循了指令:
我已经按照建议设置好了所有东西。使用了我的密钥启用了崩溃。让另一个开发人员检查了设置,看到在appcenter.ms中发生了崩溃,但我仍然没有看到任何附加信息。
下面是一个例子:
public class Application
{
// This is the main entry point of the application.
static void Main(string[] args)
{
// if you want to use a different Application Delegate class f
我的团队将一个WPF应用程序分发给一千多台机器。然而,在99.9%的时间里,应用程序都会按预期运行,但偶尔我们也会从C++那里得到一个异常。通常这是一个非常早的例外。显然,我们无法访问Visual Studio和工具(然而,我可能会分发一些独立的工具)、调试、管理员权限等。在这种情况下,我感到完全无助,只能求助于猜测。Windows EventLog帮不了什么忙。Main()方法是在生成的代码App.g.i.cs中实现的,我想它是非常标准的。我如何在它周围插入一个try/catch?它会给出任何线索吗?显然,主要目标是消除或减少猜测。
public static void Main() {
M
我使用的是来自的以下代码。
Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
@Override
public void uncaughtException(Thread paramThread, Throwable paramThrowable) {
// Catch your exception
// Without System.exit() this will n
我使用了以下代码:
Sub AppStartup()
AddHandler AppDomain.CurrentDomain.UnhandledException,
Sub(sender As Object, args As UnhandledExceptionEventArgs)
Dim e = CType(args.ExceptionObject, Exception)
ShowMessage("Oops...", HandleErr(e), MessageBoxImage.Error
让我们编写一些代码,它允许您在一个不同的AppDomain中调用一个类并处理几乎任何异常:
using System;
using System.Collections.Generic;
using System.Text;
using System.Reflection;
namespace MyAppDomain
{
class Program
{
static void Main(string[] args)
{
AppDomain myDomain = null;
try
{
myDomain = AppDo
问题上下文
我一直在我的PC上开发一个数据库应用程序(Windows 7,使用VisualStudio2010Express),它一直按照预期工作。我刚刚将最新版本复制到了运行Windows的PC上,它抛出了"Program has encountered an error and needs to close"错误消息。
Application中错误消息中的信息显示,错误发生在initializeDatabaseConnection()中(根据堆栈跟踪)--这是一个相当短的方法,只包含几行代码。
dbConnection = new MySql.Data.MySqlClien
我试图编写一个未处理的异常事件处理程序,就像在这个问题中一样。
但是给出的代码不会编译,会给出消息
error BC30590: Event 'UnhandledException' cannot be found.
怎么修?我需要导入什么东西(我是VB新手)-如果是,那又怎样?
Partial Friend Class MyApplication
Private Sub MyApplication_UnhandledException(ByVal sender As Object, ByVal e As Microsoft.VisualBasic.Applicatio
我正在尝试为无状态服务中任何未处理的异常添加一个默认的异常处理程序,但它似乎没有捕获任何异常。这是我使用的代码:
protected override async Task RunAsync(CancellationToken cancellationToken)
{
AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(this.HandleUnhandledExceptions);
throw new Exception("This is an unhandl
我使用以下代码在我的应用程序中使用NDDE
Public WithEvents DXViewDDE As New NDde.Client.DdeClient("DXView", "DDEServer", DDEClient)
Case DXViewServer
If Not DXViewDDE.IsConnected Then
Try
DXViewDDE.Connect() 'Here it throws an unhandled er