Console unhaddled event exception not kicking in

  • Thread starter Thread starter GG
  • Start date Start date
G

GG

I have a console application
[MTAThread]
static void Main(string[] args)
{
//for any unhandled exceptions
AppDomain currentDomain = AppDomain.CurrentDomain;
currentDomain.UnhandledException += new
UnhandledExceptionEventHandler(HandlerUnhandledException);

next line is
RemotingConfiguration.Configure(filename);

this is the event
public static void HandlerUnhandledException(object sender,
UnhandledExceptionEventArgs args)
{
Exception e = (Exception) args.ExceptionObject;
Console.WriteLine("Error:"+ e.Message.ToString());
Console.WriteLine(e.Source.ToString());
}

This line RemotingConfiguration.Configure(filename);
throws an exception and getting the
Just-In-time Debugging window
It does not go to the HandlerUnhandledException
I even wrapp it in
try
RemotingConfiguration.Configure(filename);
catch
but still get the Just-In-time Debugging Window


How can I use the unhaddled event exception so
I can get rid of Just-In-time Debugging Window?
 
GG wrote:
[snip]
How can I use the unhaddled event exception so
I can get rid of Just-In-time Debugging Window?

You need to add/modify the DWORD value DbgJITDebugLaunchSetting = 1 in the
the following registry key

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework

On machines with Visual Studio installed this value is by default set to 2,
what causes the behavior you observed. On machines with just the .NET
framework installed the value does not exist, what causes a slightly
different but I guess equally unwanted behavior...

Regards,

Andreas
 
You are right
now a get a different msgbox
Server.exe - Common Language Runtime Debugging Services MsgBox
Is there a way to get rid of this one too.

What I am looking for is for the app to throw the msg may be send an
e-mail and then exit gracefully.

Thanks
 
GG said:
You are right
now a get a different msgbox
Server.exe - Common Language Runtime Debugging Services MsgBox
Is there a way to get rid of this one too.

What I am looking for is for the app to throw the msg may be send an
e-mail and then exit gracefully.

I guess I was unclear, you need to set the value DbgJITDebugLaunchSetting to
1. Then everything should work as you expect.

Regards,

Andreas
 
Back
Top