C# – Visual Studio Just In Time Debugger: An unhandled Microsoft .Net Framework exception occurred

.net-4.0cwindows-xpwpf

I am trying to find the cause of the following error when I run my WPF application on Windows XP.

An unhandled Microsoft .NET Framework exception occurred in MyProgram.EXE [2672] Just-In-Time debugging this exception failed with the following error: No installed debugger has Just-In-Time debugging enabled. In Visual Studio, Just-In-Time debugging can be enabled from Tools/Options/Debugging/Just-In-Time

Check the documentation index for 'Just-in-time debugging, errods' for more information.

I used to have VS2010 running on my XP box but I have uninstalled it.

How do I get more information about what is causing the error?

I am using .Net Framework 4.0 which is installed on the Windows XP machine.

The application runs correctly on Windows 7.

[Update]

The start up object is MyProgram.App

this contains

    public partial class App : Application
{

}

stepping through on the dev machine takes me to

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

on the dev machine I next step into

MainWindow_Loaded()

however it doesn't make it this far on the XP Machine.

[Update]

I was able to edit the procedure that set up the commands

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));
         }

And this reported the error "Image Format Is UnRecognised" along with a stack trace that barely contained a line of my code.

A solution for this is documented here

I still get the Just In Time Debugger message after this

Best Answer

Try hooking up the AppDomain.UnhandledException event during app startup, and use appropriate logging to log the exception. From documentation - "Occurs when an exception is not caught." So you don't have to know where to put the try catch.. Just log it from the event.

Related Topic