We help IT Professionals succeed at work.

visual studio just-in-time debugger message box with message "an unhandled exception win 32 exception occured"

Masterabhi asked
I am using a Window Application. While running that application I got this error-
 "an unhandled exception win 32 exception occured" in Just-in-time debugger.
It crashes the application. I am using Visual studio 2008. Is ther any solution I can resolve this error?
Watch Question

Hi Masterabhi,

well, the 'just-in-time debugger' dialog is only shown on machines with installed VisualStudio. On machines without installed VisualStudio the application will crash with another message (dependant on the used Windows version).

The only way to get rid of this is to solve the bug in the application which leads to the unhandled exception.

Is this application written by you? If so you can debug the application to find the problem and hopefully a solution. If the application comes from anywhere else you have to talk to the developer(s) to solve the problem ...



I am trying to solve the bug in application but I don't want my application to be crashed when this error occurs.

Did you maybe compile your application in debug mode?
You need to compile it in release mode to run it without debugging.
There's most probably no possibility to avoid a crash in a senseful way - of course you could write something like a global try/catch to avoid the exception makes the program crash directly, but thus the application will go into an undefined state and may cause more harmful problems like damaged files, inconsistent data in a DB, a possible security vulnerability or anything else ...

The only suitable (and the preferred) way to solve this is to solve the bug which causes the exception.



Thanks for your time and reply, thought I am not able to catch that exception.
>> I don't want my application to be crashed when this error occurs.

It is best practice to handle the exception with try/catch block.If we don't handle, Dotnet framework will handle the exception and made application to crash. There is elegant way to handle unhandled exception , which does not lead application to crash. it is , adding ThreadException event to Application . When am exception is handler, application will raise the method in ThreadException.

Have a excellent article on this : http://www.codeproject.com/KB/exception/ExceptionHandling.aspx

I have attached my Program.cs for sample ThreadException event.hope thishelps.
static class Program
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        static void Main()
            Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException); 
            Application.Run(new Form1());

        static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e)
            MessageBox.Show("Exception Caught : " + e.Exception.Message);

Open in new window


it helped me