UnhandledException

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 ) ;
}
}
}
 
G

Gheorghe Marius

Hello Mike,

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

Cheers,
Marius
 
D

Dave

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.
 
M

Mike Strieder

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!!!
=======================================
 
M

Mike Strieder

Check this setting!
HKLM\Software\Microsoft\.NetFramework\DbgJitDebugLaunchSetting
 

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