UnhandledException

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Mike Strieder

    UnhandledException

    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="f alse" /> in the
    machine.config


    thx for help

    Mike

    using System;

    namespace SimpleEX
    {
    class Class1
    {
    static void Main ( )
    {
    AppDomain.Curre ntDomain.Unhand ledException +=
    new UnhandledExcept ionEventHandler ( SimpleHandler);

    String x = null ;
    Console.WriteLi ne ( x.ToString ( ) ) ;
    }

    static void SimpleHandler ( Object Sender ,
    UnhandledExcept ionEventArgs Args )
    {
    Exception e = (Exception)Args .ExceptionObjec t ;
    Console.WriteLi ne ( "Caught : " + e.Message ) ;
    }
    }
    }




  • Gheorghe Marius

    #2
    Re: UnhandledExcept ion

    Hello Mike,

    Try using the Application.Thr eadException instead of
    AppDomain.Unhan dledException.

    Cheers,
    Marius



    Comment

    • Gheorghe Marius

      #3
      Re: UnhandledExcept ion

      Hello Mike,

      Try using the Application.Thr eadException instead of
      AppDomain.Unhan dledException.

      Cheers,
      Marius



      Comment

      • Dave

        #4
        Re: UnhandledExcept ion

        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.

        "Mike Strieder" <nobody@nobody. com> wrote in message
        news:OVeDyZAWDH A.392@TK2MSFTNG P11.phx.gbl...[color=blue]
        > it's in an windows service - there is no Application...
        >
        > i try also:
        >
        > System.Threadin g.Thread.GetDom ain().Unhandled Exception += new
        > UnhandledExcept ionEventHandler (MyHandler);
        > AppDomain.Curre ntDomain.Unhand ledException += new
        > UnhandledExcept ionEventHandler (MyHandler);
        >
        >
        > "Gheorghe Marius" <cghostsoft@hot mail.com> schrieb im Newsbeitrag
        > news:upwT0BAWDH A.2224@TK2MSFTN GP09.phx.gbl...[color=green]
        > > Hello Mike,
        > >
        > > Try using the Application.Thr eadException instead of
        > > AppDomain.Unhan dledException.
        > >
        > > Cheers,
        > > Marius
        > >
        > >
        > >[/color]
        >
        >[/color]


        Comment

        • Dave

          #5
          Re: UnhandledExcept ion

          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.

          "Mike Strieder" <nobody@nobody. com> wrote in message
          news:OVeDyZAWDH A.392@TK2MSFTNG P11.phx.gbl...[color=blue]
          > it's in an windows service - there is no Application...
          >
          > i try also:
          >
          > System.Threadin g.Thread.GetDom ain().Unhandled Exception += new
          > UnhandledExcept ionEventHandler (MyHandler);
          > AppDomain.Curre ntDomain.Unhand ledException += new
          > UnhandledExcept ionEventHandler (MyHandler);
          >
          >
          > "Gheorghe Marius" <cghostsoft@hot mail.com> schrieb im Newsbeitrag
          > news:upwT0BAWDH A.2224@TK2MSFTN GP09.phx.gbl...[color=green]
          > > Hello Mike,
          > >
          > > Try using the Application.Thr eadException instead of
          > > AppDomain.Unhan dledException.
          > >
          > > Cheers,
          > > Marius
          > >
          > >
          > >[/color]
          >
          >[/color]


          Comment

          • Mike Strieder

            #6
            Re: UnhandledExcept ion

            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.Curre ntDomain.Unhand ledException +=
            new UnhandledExcept ionEventHandler ( MyHandler);

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

            static void MyHandler( Object Sender , UnhandledExcept ionEventArgs
            Args )
            {
            Exception e = (Exception)Args .ExceptionObjec t ;
            Console.WriteLi ne ( "Caught : " + e.Message ) ;
            }
            }
            }

            the goal is not to raise up the JIT-Debugger!!!
            =============== =============== =========



            "Dave" <kdlevine@wi.rr .com> schrieb im Newsbeitrag
            news:Ohu258AWDH A.1896@TK2MSFTN GP12.phx.gbl...[color=blue]
            > 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[/color]
            hooks[color=blue]
            > the handler is never getting called.
            >
            > "Mike Strieder" <nobody@nobody. com> wrote in message
            > news:OVeDyZAWDH A.392@TK2MSFTNG P11.phx.gbl...[color=green]
            > > it's in an windows service - there is no Application...
            > >
            > > i try also:
            > >
            > > System.Threadin g.Thread.GetDom ain().Unhandled Exception += new
            > > UnhandledExcept ionEventHandler (MyHandler);
            > > AppDomain.Curre ntDomain.Unhand ledException += new
            > > UnhandledExcept ionEventHandler (MyHandler);
            > >
            > >
            > > "Gheorghe Marius" <cghostsoft@hot mail.com> schrieb im Newsbeitrag
            > > news:upwT0BAWDH A.2224@TK2MSFTN GP09.phx.gbl...[color=darkred]
            > > > Hello Mike,
            > > >
            > > > Try using the Application.Thr eadException instead of
            > > > AppDomain.Unhan dledException.
            > > >
            > > > Cheers,
            > > > Marius
            > > >
            > > >
            > > >[/color]
            > >
            > >[/color]
            >
            >[/color]


            Comment

            • Mike Strieder

              #7
              Re: UnhandledExcept ion

              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.Curre ntDomain.Unhand ledException +=
              new UnhandledExcept ionEventHandler ( MyHandler);

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

              static void MyHandler( Object Sender , UnhandledExcept ionEventArgs
              Args )
              {
              Exception e = (Exception)Args .ExceptionObjec t ;
              Console.WriteLi ne ( "Caught : " + e.Message ) ;
              }
              }
              }

              the goal is not to raise up the JIT-Debugger!!!
              =============== =============== =========



              "Dave" <kdlevine@wi.rr .com> schrieb im Newsbeitrag
              news:Ohu258AWDH A.1896@TK2MSFTN GP12.phx.gbl...[color=blue]
              > 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[/color]
              hooks[color=blue]
              > the handler is never getting called.
              >
              > "Mike Strieder" <nobody@nobody. com> wrote in message
              > news:OVeDyZAWDH A.392@TK2MSFTNG P11.phx.gbl...[color=green]
              > > it's in an windows service - there is no Application...
              > >
              > > i try also:
              > >
              > > System.Threadin g.Thread.GetDom ain().Unhandled Exception += new
              > > UnhandledExcept ionEventHandler (MyHandler);
              > > AppDomain.Curre ntDomain.Unhand ledException += new
              > > UnhandledExcept ionEventHandler (MyHandler);
              > >
              > >
              > > "Gheorghe Marius" <cghostsoft@hot mail.com> schrieb im Newsbeitrag
              > > news:upwT0BAWDH A.2224@TK2MSFTN GP09.phx.gbl...[color=darkred]
              > > > Hello Mike,
              > > >
              > > > Try using the Application.Thr eadException instead of
              > > > AppDomain.Unhan dledException.
              > > >
              > > > Cheers,
              > > > Marius
              > > >
              > > >
              > > >[/color]
              > >
              > >[/color]
              >
              >[/color]


              Comment

              • Mike Strieder

                #8
                Re: UnhandledExcept ion

                Check this setting!
                HKLM\Software\M icrosoft\.NetFr amework\DbgJitD ebugLaunchSetti ng

                "Mike Strieder" <nobody@nobody. com> schrieb im Newsbeitrag
                news:ecR#ul$VDH A.532@TK2MSFTNG P09.phx.gbl...[color=blue]
                > 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="f alse" /> in the
                > machine.config
                >
                >
                > thx for help
                >
                > Mike
                >
                > using System;
                >
                > namespace SimpleEX
                > {
                > class Class1
                > {
                > static void Main ( )
                > {
                > AppDomain.Curre ntDomain.Unhand ledException +=
                > new UnhandledExcept ionEventHandler ( SimpleHandler);
                >
                > String x = null ;
                > Console.WriteLi ne ( x.ToString ( ) ) ;
                > }
                >
                > static void SimpleHandler ( Object Sender ,
                > UnhandledExcept ionEventArgs Args )
                > {
                > Exception e = (Exception)Args .ExceptionObjec t ;
                > Console.WriteLi ne ( "Caught : " + e.Message ) ;
                > }
                > }
                > }
                >
                >
                >
                >[/color]


                Comment

                Working...