Unhandled Exception handler

  • Thread starter Thread starter Ken
  • Start date Start date
K

Ken

I'm trying to install an UnhandledException handler in a Console
application. I have done the following as the first few lines of code in
Main:

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

Then my handler is defined:

public static void HandleTheException ( object sender,
UnhandledExceptionEventArgs e )
{
Console.WriteLine ( "Exception: {0}",
(Exception)e.ExceptionObject).Message );
Console.ReadLine ( );
}

When an UnhandledException is thrown and I have the JIT debbugging options
all UN checked I still get a dialog that has "Common Language Runtime
Debugging Services" in the title bar and a message saying that the
application has generated an exception that could not be handled. Click OK
to terminate that application or Click CANCEL to debug the application. If
I click OK then my handler gets invoked.

Is there any way to disable this dialog box? I just want my handler to do
all the work with no other dialogs.

Thanks

Ken
 
Hi Ken,

Thanks for your post. As I understand, you want to disable the JIT debugger
dialog box when running the app within the VS .NET debugger. Please correct
me if there is any misunderstanding. You have to make the following
settings:

a. Select the menu "Debug" ->"Exceptions", and Exceptions dialog comes up.

b. Make the following settings: in "Common Language Runtime Exception" ->
"System" -> "System.Exception", change the settings to "Continue" for both
types of exception handling.

c. Please kindly note that you can disable debug mode debugging for certain
types of exceptions with this menu options, but not when the app is running
alone without the debugger.

Hope this helps.

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
I'm sorry for not being clear. This dialog box is displayed when running
the application outside Visual Studio. That is what I am trying to stop
from displaying.

Thank You

Ken
 
Hello Ken,

Thanks for your response. If you want to disable the JIT debugger dialogue
box when running the app alone without the debugger, please perform the
following step:

Change the following registry key:

HKEY_LOCAL_MACHINE\Software\Microsoft\.NetFramework\DbgJITDebugLaunchSetting
to the value 1 will disable JIT debugging.

Please let me know the result.

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
Back
Top