Console unhaddled event exception not kicking in

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?
 
A

Andreas Huber

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
 
G

GG

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
 
A

Andreas Huber

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top