Visual Studio及时调试程序:发生了未处理的Microsoft .Net Framework异常

时间:2014-11-30 02:06:22

标签: c# wpf .net-4.0 windows-xp

我试图在Windows XP上运行WPF应用程序时找到以下错误的原因。

  

MyProgram.EXE中发生未处理的Microsoft .NET Framework异常[2672]即时调试此异常失败,并显示以下错误:未安装的调试器启用了即时调试。在Visual Studio中,可以从工具/选项/调试/即时启用即时调试

     

检查文档索引以及'及时调试,errods'了解更多信息。

我曾经在我的XP机箱上运行VS2010,但我已经卸载了它。

如何获得有关导致错误的更多信息?

我正在使用安装在Windows XP计算机上的.Net Framework 4.0。

应用程序在Windows 7上正常运行。

[更新]

启动对象是MyProgram.App

这包含

    public partial class App : Application
{

}

单步执行dev机器将我带到

public MainWindow()
        {
           // various controller set up commands
        }

在dev机器上我下一步进入

MainWindow_Loaded()
然而,它并没有在XP机器上做到这一点。

[更新]

我能够编辑设置命令的过程

private void WireupCommands()
        {

            AppDomain currentDomain = AppDomain.CurrentDomain;
            currentDomain.UnhandledException += new UnhandledExceptionEventHandler(MyHandler);

            this.CommandBindings.Add(new CommandBinding(MainCommands.AppExit, MainExitCmdExecuted, AlwaysCanExecute));  // etc
         }

static void MyHandler(object sender, UnhandledExceptionEventArgs args)
        {

            Exception e = (Exception)args.ExceptionObject;
            MessageBox.Show(string.Format("{0} {1}", e.Message, e.StackTrace));
         }

这报告了错误"图像格式无法识别"以及几乎不包含我的代码行的堆栈跟踪。

此解决方案记录在here

在此

之后我仍然收到Just In Time Debugger消息

1 个答案:

答案 0 :(得分:1)

尝试在应用启动期间连接AppDomain.UnhandledException事件,并使用适当的日志记录来记录异常。来自文档 - “当一个例外被捕获时发生。”所以你不必知道放置try catch的位置..只需从事件中记录它。