UnhandledException

  • Thread starter Thread starter Mike Strieder
  • Start date Start date
M

Mike Strieder

i want to catch all execeptions with my own handler, but the problem is,
that the JIT-Debugger always start!
i put also the <system.windows.forms jitDebugging="false" /> in the
machine.config


thx for help

Mike

using System;

namespace SimpleEX
{
class Class1
{
static void Main ( )
{
AppDomain.CurrentDomain.UnhandledException +=
new UnhandledExceptionEventHandler ( SimpleHandler);

String x = null ;
Console.WriteLine ( x.ToString ( ) ) ;
}

static void SimpleHandler ( Object Sender ,
UnhandledExceptionEventArgs Args )
{
Exception e = (Exception)Args.ExceptionObject ;
Console.WriteLine ( "Caught : " + e.Message ) ;
}
}
}
 
Hello Mike,

Try using the Application.ThreadException instead of
AppDomain.UnhandledException.

Cheers,
Marius
 
If it's a windows service then there's a bunch of code missing from your
sample. I'd guess that even though you think the Main method is getting
called, it really isn't. Windows services use a different mechanism - the
service control manager calls a special entry point. So the code that hooks
the handler is never getting called.
 
Hi Dave,

the service is working very fine and it also start in Main.
But the Problem is that an unhandelt Execption raise up the JIT-Debugger and
not jump direct to MyHandler.

i have also the problem with an in an Console Application

using System;

namespace SimpleEX
{
class Class1
{
static void Main ( )
{
AppDomain.CurrentDomain.UnhandledException +=
new UnhandledExceptionEventHandler ( MyHandler);

String x = null ;
Console.WriteLine ( x.ToString ( ) ) ; // <---- raise an
exception to the JIT-Debugger not direct to MyHandler
}

static void MyHandler( Object Sender , UnhandledExceptionEventArgs
Args )
{
Exception e = (Exception)Args.ExceptionObject ;
Console.WriteLine ( "Caught : " + e.Message ) ;
}
}
}

the goal is not to raise up the JIT-Debugger!!!
=======================================
 
Check this setting!
HKLM\Software\Microsoft\.NetFramework\DbgJitDebugLaunchSetting
 
Back
Top