Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. AppDomain Question [modified]

AppDomain Question [modified]

Scheduled Pinned Locked Moved Visual Basic
question
6 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mtone
    wrote on last edited by
    #1

    I have an MDI form where I set the following Handler in Form_Load AddHandler AppDomain.CurrentDomain.UnhandledException, AddressOf CurrentDomain_UnhandledException If I throw an exception in the MDI form the exception gets handled by CurrentDomain_UnhandledException But, If I load a child form and throw an exception from the child form the excpetion does not get handled by CurrentDomain_UnhandledException So, Is the child form running in a different AppDomain then the MDI form. How can I get this to work or does this not work the way I thought it would. Here is my form load which is also in the MDI form f = New formDesignErrorsList f.Tag = formname f.Text = f.Text f.MdiParent = Me f.Show() Thanks -- modified at 22:46 Wednesday 23rd August, 2006

    D 1 Reply Last reply
    0
    • M mtone

      I have an MDI form where I set the following Handler in Form_Load AddHandler AppDomain.CurrentDomain.UnhandledException, AddressOf CurrentDomain_UnhandledException If I throw an exception in the MDI form the exception gets handled by CurrentDomain_UnhandledException But, If I load a child form and throw an exception from the child form the excpetion does not get handled by CurrentDomain_UnhandledException So, Is the child form running in a different AppDomain then the MDI form. How can I get this to work or does this not work the way I thought it would. Here is my form load which is also in the MDI form f = New formDesignErrorsList f.Tag = formname f.Text = f.Text f.MdiParent = Me f.Show() Thanks -- modified at 22:46 Wednesday 23rd August, 2006

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      mtone wrote:

      Is the child form running in a different AppDomain then the MDI form.

      No, it's not. It's all in the same AppDomain. What's the exception that's not getting handled?

      Dave Kreskowiak Microsoft MVP - Visual Basic

      M 1 Reply Last reply
      0
      • D Dave Kreskowiak

        mtone wrote:

        Is the child form running in a different AppDomain then the MDI form.

        No, it's not. It's all in the same AppDomain. What's the exception that's not getting handled?

        Dave Kreskowiak Microsoft MVP - Visual Basic

        M Offline
        M Offline
        mtone
        wrote on last edited by
        #3

        In the Main (MDI) form My test is just trowing an new exception. Here is gets handled by CurrentDomain_UnhandledException and ultimatly ends up in The EventLog Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load AddHandler Application.ThreadException, AddressOf ApplicationThreadException AddHandler AppDomain.CurrentDomain.UnhandledException, AddressOf CurrentDomain_UnhandledException Throw New Exception("This is a test") End Sub If I put the same Throw New Exception("This is a test") in the onload event of the mdi child it does not get handled nor does it make it to the event log. If I set a break point I can see that CurrentDomain_UnhandledException is never called. Thanks Joe

        D 1 Reply Last reply
        0
        • M mtone

          In the Main (MDI) form My test is just trowing an new exception. Here is gets handled by CurrentDomain_UnhandledException and ultimatly ends up in The EventLog Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load AddHandler Application.ThreadException, AddressOf ApplicationThreadException AddHandler AppDomain.CurrentDomain.UnhandledException, AddressOf CurrentDomain_UnhandledException Throw New Exception("This is a test") End Sub If I put the same Throw New Exception("This is a test") in the onload event of the mdi child it does not get handled nor does it make it to the event log. If I set a break point I can see that CurrentDomain_UnhandledException is never called. Thanks Joe

          D Offline
          D Offline
          Dave Kreskowiak
          wrote on last edited by
          #4

          Well, I did this and it did what was expected of it:

          ' Form1
          Private Sub Form1_Load(blah, blah) Handles Me.Load
          AddHandler AppDomain.CurrentDomain.UnhandledException, AddressOf UnhandledExceptionHandler
          Dim c As New Form2
          c.MdiParent = Me
          c.Show()
          End Sub
           
          Private Sub UnhandledExceptionHandler(ByVal sender As Object, ByVal e As UnhandledExceptionEventArgs)
          Debug.WriteLine("Unhandled Exception!!")
          End Sub
           
           
          ' Form2
          Private Sub Form2_Load(blah, blah) Handles Me.Load
          Throw New Exception("Yikes!")
          End Sub

          The exceptions don't make it to the event log because there's nothing telling the app to log them. But, the exception was caught by the UnhandledExceptionHandler.

          Dave Kreskowiak Microsoft MVP - Visual Basic

          M 1 Reply Last reply
          0
          • D Dave Kreskowiak

            Well, I did this and it did what was expected of it:

            ' Form1
            Private Sub Form1_Load(blah, blah) Handles Me.Load
            AddHandler AppDomain.CurrentDomain.UnhandledException, AddressOf UnhandledExceptionHandler
            Dim c As New Form2
            c.MdiParent = Me
            c.Show()
            End Sub
             
            Private Sub UnhandledExceptionHandler(ByVal sender As Object, ByVal e As UnhandledExceptionEventArgs)
            Debug.WriteLine("Unhandled Exception!!")
            End Sub
             
             
            ' Form2
            Private Sub Form2_Load(blah, blah) Handles Me.Load
            Throw New Exception("Yikes!")
            End Sub

            The exceptions don't make it to the event log because there's nothing telling the app to log them. But, the exception was caught by the UnhandledExceptionHandler.

            Dave Kreskowiak Microsoft MVP - Visual Basic

            M Offline
            M Offline
            mtone
            wrote on last edited by
            #5

            Thanks Dave I have the code that writes to the event log in another function I am using the Enterprise Library to handle the event logging. Well, the event log was not the problem just a way for me to see the exception followed the proper route. I will keep looking at it, so long as I know it should work.

            D 1 Reply Last reply
            0
            • M mtone

              Thanks Dave I have the code that writes to the event log in another function I am using the Enterprise Library to handle the event logging. Well, the event log was not the problem just a way for me to see the exception followed the proper route. I will keep looking at it, so long as I know it should work.

              D Offline
              D Offline
              Dave Kreskowiak
              wrote on last edited by
              #6

              In my testing, there is a problem with using the UnhandledException event. It doesn't get fired unless the code is running under the debugger! Go figure...

              Dave Kreskowiak Microsoft MVP - Visual Basic

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups