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. Cannot close application in or outside of debugger

Cannot close application in or outside of debugger

Scheduled Pinned Locked Moved Visual Basic
helpvisual-studiodebuggingquestion
24 Posts 10 Posters 1 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.
  • A Offline
    A Offline
    Alan Burkhart
    wrote on last edited by
    #1

    I have a single-thread project that's been working fine until tonight. Everything goes well until I try to close it. No error msg, it doesn't freeze. But it won't close. In VS I have to hit the Stop Debugging button. If I run it from a shortcut, I have to use Task Manager to close it (and I get a Not Responding msg). The only changes I've made tonight was to add a tab control, one page with a WebBrowser and one with a ScintillaNet control. The ScintillaNet control was already in use and I simply moved it to a tabpage. I undid all this but the problem still exists. Closed and restarted VS and that didn't help. Commented out everything in the FormClosing sub - no effect. Other projects close without issue. Suggestions?

    If Barney Frank eats a fruitcake, is it cannibalism?

    L P A 3 Replies Last reply
    0
    • A Alan Burkhart

      I have a single-thread project that's been working fine until tonight. Everything goes well until I try to close it. No error msg, it doesn't freeze. But it won't close. In VS I have to hit the Stop Debugging button. If I run it from a shortcut, I have to use Task Manager to close it (and I get a Not Responding msg). The only changes I've made tonight was to add a tab control, one page with a WebBrowser and one with a ScintillaNet control. The ScintillaNet control was already in use and I simply moved it to a tabpage. I undid all this but the problem still exists. Closed and restarted VS and that didn't help. Commented out everything in the FormClosing sub - no effect. Other projects close without issue. Suggestions?

      If Barney Frank eats a fruitcake, is it cannibalism?

      L Offline
      L Offline
      Luc Pattyn
      wrote on last edited by
      #2

      Open Task Manager and watch CPU load. Either your app is in an eternal loop (total CPU load = 100% divided by number of cores), or it is deadlocked (two threads waiting for a resource/lock the other is holding). BTW: are you absolutely sure your app is single-threaded? that requires you don't use any callbacks, no timers, no asynchronous operations, no ... :)

      Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum

      Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.

      A C 2 Replies Last reply
      0
      • L Luc Pattyn

        Open Task Manager and watch CPU load. Either your app is in an eternal loop (total CPU load = 100% divided by number of cores), or it is deadlocked (two threads waiting for a resource/lock the other is holding). BTW: are you absolutely sure your app is single-threaded? that requires you don't use any callbacks, no timers, no asynchronous operations, no ... :)

        Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum

        Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.

        A Offline
        A Offline
        Alan Burkhart
        wrote on last edited by
        #3

        Luc Pattyn wrote:

        Open Task Manager and watch CPU load. Either your app is in an eternal loop (total CPU load = 100% divided by number of cores), or it is deadlocked (two threads waiting for a resource/lock the other is holding).

        CPU load stays at 4 to 8 percent.

        Luc Pattyn wrote:

        BTW: are you absolutely sure your app is single-threaded? that requires you don't use any callbacks, no timers, no asynchronous operations, no ...

        None of that stuff. I just wanted a super-simple PHP/HTML editor. Just opens, edits and saves php/html files. It's just a temp workaround, but I added Me.Dispose at the end of the Me.Close sub and it closes without issue. That of course doesn't explain (at least not to me) why it suddenly quit closing properly. I removed this before looking at the cpu load, btw.

        If Barney Frank eats a fruitcake, is it cannibalism?

        L 1 Reply Last reply
        0
        • A Alan Burkhart

          Luc Pattyn wrote:

          Open Task Manager and watch CPU load. Either your app is in an eternal loop (total CPU load = 100% divided by number of cores), or it is deadlocked (two threads waiting for a resource/lock the other is holding).

          CPU load stays at 4 to 8 percent.

          Luc Pattyn wrote:

          BTW: are you absolutely sure your app is single-threaded? that requires you don't use any callbacks, no timers, no asynchronous operations, no ...

          None of that stuff. I just wanted a super-simple PHP/HTML editor. Just opens, edits and saves php/html files. It's just a temp workaround, but I added Me.Dispose at the end of the Me.Close sub and it closes without issue. That of course doesn't explain (at least not to me) why it suddenly quit closing properly. I removed this before looking at the cpu load, btw.

          If Barney Frank eats a fruitcake, is it cannibalism?

          L Offline
          L Offline
          Luc Pattyn
          wrote on last edited by
          #4

          Alan Burkhart wrote:

          CPU load stays at 4 to 8 percent.

          Not a busy loop then. Sounds strange. Where are Me.Close and Me.Dispose located in your source? in some event handler? :)

          Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum

          Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.

          A 1 Reply Last reply
          0
          • L Luc Pattyn

            Alan Burkhart wrote:

            CPU load stays at 4 to 8 percent.

            Not a busy loop then. Sounds strange. Where are Me.Close and Me.Dispose located in your source? in some event handler? :)

            Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum

            Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.

            A Offline
            A Offline
            Alan Burkhart
            wrote on last edited by
            #5

            Luc Pattyn wrote:

            Where are Me.Close and Me.Dispose located in your source? in some event handler?

            The "Exit" menu item's click event:

            Private Sub CloseApp() Handles menuFile_Exit.Click
            Try
            Me.Close()
            Catch ex As Exception
            MsgBox(ex.ToString, MsgBoxStyle.Exclamation, title)
            End Try
            End Sub

            I added Me.Dispose to the end of the FormClosing event handler. Too much code to list here, but all FormClosing does is save preferences, recently used docs and open tabs. Nothing complicated. I disabled (commented) all the code in the FormClosing sub to see if something there was causing the problem. No change. Weird, huh?

            If Barney Frank eats a fruitcake, is it cannibalism?

            L 1 Reply Last reply
            0
            • A Alan Burkhart

              Luc Pattyn wrote:

              Where are Me.Close and Me.Dispose located in your source? in some event handler?

              The "Exit" menu item's click event:

              Private Sub CloseApp() Handles menuFile_Exit.Click
              Try
              Me.Close()
              Catch ex As Exception
              MsgBox(ex.ToString, MsgBoxStyle.Exclamation, title)
              End Try
              End Sub

              I added Me.Dispose to the end of the FormClosing event handler. Too much code to list here, but all FormClosing does is save preferences, recently used docs and open tabs. Nothing complicated. I disabled (commented) all the code in the FormClosing sub to see if something there was causing the problem. No change. Weird, huh?

              If Barney Frank eats a fruitcake, is it cannibalism?

              L Offline
              L Offline
              Luc Pattyn
              wrote on last edited by
              #6

              weird indeed. Here is some info you probably already know, and some suggestions: - Closing and Closed events are obsolete, use FormClosing and FormClosed instead; - there could be more than one handler associated with form closing; - if form disposing at the end of FormClosing solves the problem, seems like something goes wrong inside FormClosed handler; - you could consider calling Application.Exit() instead of Me.Close() :)

              Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum

              Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.

              A 1 Reply Last reply
              0
              • L Luc Pattyn

                weird indeed. Here is some info you probably already know, and some suggestions: - Closing and Closed events are obsolete, use FormClosing and FormClosed instead; - there could be more than one handler associated with form closing; - if form disposing at the end of FormClosing solves the problem, seems like something goes wrong inside FormClosed handler; - you could consider calling Application.Exit() instead of Me.Close() :)

                Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum

                Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.

                A Offline
                A Offline
                Alan Burkhart
                wrote on last edited by
                #7

                Tried Application.Exit() but it didn't change anything. I'm using FormClosing, but not FormClosed. Only one eventhandler for FormClosing. I gotta get off of here for tonight. Early start / long day tomorrow. I'll work on it again tomorrow. As always, thanks for your help. :)

                If Barney Frank eats a fruitcake, is it cannibalism?

                L G 2 Replies Last reply
                0
                • A Alan Burkhart

                  Tried Application.Exit() but it didn't change anything. I'm using FormClosing, but not FormClosed. Only one eventhandler for FormClosing. I gotta get off of here for tonight. Early start / long day tomorrow. I'll work on it again tomorrow. As always, thanks for your help. :)

                  If Barney Frank eats a fruitcake, is it cannibalism?

                  L Offline
                  L Offline
                  Luc Pattyn
                  wrote on last edited by
                  #8

                  New ideas: 1. any chance the ScintillaNet creates a non-background thread? does it offer methods to terminate itself, a close/dispose/whatever? if so, consider calling them in FormClosing. 2. the change you introduced by moving the ScintillaNet from your Form to a TabPage could be this: on the Form it starts in a visible state, on any non-first TabPage it initially is invisible, therefore it might work a little differently. Experiment: change the order of the TabPages, so ScintillaNet is visible right away. If #1 does not help and #2 does, time to contact the ScintillaNet provider. :)

                  Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum

                  Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.

                  A 1 Reply Last reply
                  0
                  • L Luc Pattyn

                    New ideas: 1. any chance the ScintillaNet creates a non-background thread? does it offer methods to terminate itself, a close/dispose/whatever? if so, consider calling them in FormClosing. 2. the change you introduced by moving the ScintillaNet from your Form to a TabPage could be this: on the Form it starts in a visible state, on any non-first TabPage it initially is invisible, therefore it might work a little differently. Experiment: change the order of the TabPages, so ScintillaNet is visible right away. If #1 does not help and #2 does, time to contact the ScintillaNet provider. :)

                    Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum

                    Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.

                    A Offline
                    A Offline
                    Alan Burkhart
                    wrote on last edited by
                    #9

                    Luc Pattyn wrote:

                    any chance the ScintillaNet creates a non-background thread? does it offer methods to terminate itself, a close/dispose/whatever? if so, consider calling them in FormClosing.

                    Never needed to do this before but tried it nonetheless. Didn't help. I disposed each ScintillaNet object individually.

                    Luc Pattyn wrote:

                    the change you introduced by moving the ScintillaNet from your Form to a TabPage could be this: on the Form it starts in a visible state, on any non-first TabPage it initially is invisible, therefore it might work a little differently. Experiment: change the order of the TabPages, so ScintillaNet is visible right away.

                    The ScintillaNet control is on the first tabpage. I also removed the new tabcontrol so that the program was like it was before the problem appeared (ScintillaNet docked in the form). No change. I've been using ScintillaNet in place of a TextBox for a couple of years and never encountered this before. I've swapped the StartUp form to a couple of others and they close fine. I may try creating a new form and piece meal the existing code onto it to see if I can track down the cause. Who knows? It may be that the form itself is corrupt.

                    If Barney Frank eats a fruitcake, is it cannibalism?

                    L O 2 Replies Last reply
                    0
                    • A Alan Burkhart

                      Luc Pattyn wrote:

                      any chance the ScintillaNet creates a non-background thread? does it offer methods to terminate itself, a close/dispose/whatever? if so, consider calling them in FormClosing.

                      Never needed to do this before but tried it nonetheless. Didn't help. I disposed each ScintillaNet object individually.

                      Luc Pattyn wrote:

                      the change you introduced by moving the ScintillaNet from your Form to a TabPage could be this: on the Form it starts in a visible state, on any non-first TabPage it initially is invisible, therefore it might work a little differently. Experiment: change the order of the TabPages, so ScintillaNet is visible right away.

                      The ScintillaNet control is on the first tabpage. I also removed the new tabcontrol so that the program was like it was before the problem appeared (ScintillaNet docked in the form). No change. I've been using ScintillaNet in place of a TextBox for a couple of years and never encountered this before. I've swapped the StartUp form to a couple of others and they close fine. I may try creating a new form and piece meal the existing code onto it to see if I can track down the cause. Who knows? It may be that the form itself is corrupt.

                      If Barney Frank eats a fruitcake, is it cannibalism?

                      L Offline
                      L Offline
                      Luc Pattyn
                      wrote on last edited by
                      #10

                      Sounds like a plan. :thumbsup:

                      Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum

                      Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.

                      A 1 Reply Last reply
                      0
                      • A Alan Burkhart

                        Luc Pattyn wrote:

                        any chance the ScintillaNet creates a non-background thread? does it offer methods to terminate itself, a close/dispose/whatever? if so, consider calling them in FormClosing.

                        Never needed to do this before but tried it nonetheless. Didn't help. I disposed each ScintillaNet object individually.

                        Luc Pattyn wrote:

                        the change you introduced by moving the ScintillaNet from your Form to a TabPage could be this: on the Form it starts in a visible state, on any non-first TabPage it initially is invisible, therefore it might work a little differently. Experiment: change the order of the TabPages, so ScintillaNet is visible right away.

                        The ScintillaNet control is on the first tabpage. I also removed the new tabcontrol so that the program was like it was before the problem appeared (ScintillaNet docked in the form). No change. I've been using ScintillaNet in place of a TextBox for a couple of years and never encountered this before. I've swapped the StartUp form to a couple of others and they close fine. I may try creating a new form and piece meal the existing code onto it to see if I can track down the cause. Who knows? It may be that the form itself is corrupt.

                        If Barney Frank eats a fruitcake, is it cannibalism?

                        O Offline
                        O Offline
                        Oakman
                        wrote on last edited by
                        #11

                        Your own idea of recreating the form and adding control by control and code block by code block is one I have used successfully.

                        Never mind who, where is John Galt when we need him?

                        A 1 Reply Last reply
                        0
                        • O Oakman

                          Your own idea of recreating the form and adding control by control and code block by code block is one I have used successfully.

                          Never mind who, where is John Galt when we need him?

                          A Offline
                          A Offline
                          Alan Burkhart
                          wrote on last edited by
                          #12

                          Oakman wrote:

                          Your own idea of recreating the form and adding control by control and code block by code block is one I have used successfully.

                          Yep, I'm about to get into that very thing. I can't find one thing wrong with the existing form and I'm wondering if the file is corrupt down in some level I cannot access.

                          If Barney Frank eats a fruitcake, is it cannibalism?

                          L T 2 Replies Last reply
                          0
                          • A Alan Burkhart

                            Oakman wrote:

                            Your own idea of recreating the form and adding control by control and code block by code block is one I have used successfully.

                            Yep, I'm about to get into that very thing. I can't find one thing wrong with the existing form and I'm wondering if the file is corrupt down in some level I cannot access.

                            If Barney Frank eats a fruitcake, is it cannibalism?

                            L Offline
                            L Offline
                            Luc Pattyn
                            wrote on last edited by
                            #13

                            Alan Burkhart wrote:

                            in some level I cannot access

                            you may have discovered some anti-Higgs particles in the bits of your Form... :-D

                            Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum

                            Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.

                            1 Reply Last reply
                            0
                            • L Luc Pattyn

                              Sounds like a plan. :thumbsup:

                              Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum

                              Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.

                              A Offline
                              A Offline
                              Alan Burkhart
                              wrote on last edited by
                              #14

                              I finally gave up and created a new project. Copied the controls and code from the offending form to the new project one block at a time, looking for the cause. It never materialized. New project works fine. I may never know what caused it. I'm going to just let this one go. Thanks for trying. This one was just too weird to keep chasing. :)

                              If Barney Frank eats a fruitcake, is it cannibalism?

                              L A 2 Replies Last reply
                              0
                              • A Alan Burkhart

                                I finally gave up and created a new project. Copied the controls and code from the offending form to the new project one block at a time, looking for the cause. It never materialized. New project works fine. I may never know what caused it. I'm going to just let this one go. Thanks for trying. This one was just too weird to keep chasing. :)

                                If Barney Frank eats a fruitcake, is it cannibalism?

                                L Offline
                                L Offline
                                Luc Pattyn
                                wrote on last edited by
                                #15

                                Well done. Trying to understand and fix is excellent, stepping over it when normal measures don't work is quite acceptable. :thumbsup:

                                Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum

                                Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.

                                1 Reply Last reply
                                0
                                • A Alan Burkhart

                                  I finally gave up and created a new project. Copied the controls and code from the offending form to the new project one block at a time, looking for the cause. It never materialized. New project works fine. I may never know what caused it. I'm going to just let this one go. Thanks for trying. This one was just too weird to keep chasing. :)

                                  If Barney Frank eats a fruitcake, is it cannibalism?

                                  A Offline
                                  A Offline
                                  AspDotNetDev
                                  wrote on last edited by
                                  #16

                                  You may want to use WinMerge to compare the differences between your old and new project. Who knows, maybe something will stick out.

                                  [

                                  S<T>::f(U) // Out of line.

                                  ](http://msdn.microsoft.com/en-us/library/8yk3t00s(v=vs.71).aspx)

                                  A 1 Reply Last reply
                                  0
                                  • A Alan Burkhart

                                    Oakman wrote:

                                    Your own idea of recreating the form and adding control by control and code block by code block is one I have used successfully.

                                    Yep, I'm about to get into that very thing. I can't find one thing wrong with the existing form and I'm wondering if the file is corrupt down in some level I cannot access.

                                    If Barney Frank eats a fruitcake, is it cannibalism?

                                    T Offline
                                    T Offline
                                    trantrum
                                    wrote on last edited by
                                    #17

                                    Using C# in Visual Studio 2005 I have had this problem using databound controls. If the user enters a value in a databound textbox that expects a value, then deletes the value, the program will not allow the user to leave the textbox, even to exit the program. You cannot do anything except re-enter a value. Dennis

                                    1 Reply Last reply
                                    0
                                    • A Alan Burkhart

                                      I have a single-thread project that's been working fine until tonight. Everything goes well until I try to close it. No error msg, it doesn't freeze. But it won't close. In VS I have to hit the Stop Debugging button. If I run it from a shortcut, I have to use Task Manager to close it (and I get a Not Responding msg). The only changes I've made tonight was to add a tab control, one page with a WebBrowser and one with a ScintillaNet control. The ScintillaNet control was already in use and I simply moved it to a tabpage. I undid all this but the problem still exists. Closed and restarted VS and that didn't help. Commented out everything in the FormClosing sub - no effect. Other projects close without issue. Suggestions?

                                      If Barney Frank eats a fruitcake, is it cannibalism?

                                      P Offline
                                      P Offline
                                      patbob
                                      wrote on last edited by
                                      #18

                                      Your UI thread isn't checking and processing windows messages. That's why you still have a window, CPU usage for the process is >0%, it won't exit, and you get a not-responding when you send a window close message to it with task manager (aka "use Task Manager to close it"). Might be worthwhile to configure VS to use the MS symbol server, then break the process. Find the UI thread (might be called "MainThread") and look at it's stack to see where its stuck. With any luck, the culprit will be obvious, but probably not since that thread is polling something and it probably looping in code that isn't yours. Good luck.

                                      patbob

                                      1 Reply Last reply
                                      0
                                      • L Luc Pattyn

                                        Open Task Manager and watch CPU load. Either your app is in an eternal loop (total CPU load = 100% divided by number of cores), or it is deadlocked (two threads waiting for a resource/lock the other is holding). BTW: are you absolutely sure your app is single-threaded? that requires you don't use any callbacks, no timers, no asynchronous operations, no ... :)

                                        Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum

                                        Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.

                                        C Offline
                                        C Offline
                                        Chris Trelawny Ross
                                        wrote on last edited by
                                        #19

                                        Luc Pattyn wrote:

                                        eternal loop

                                        - so much more poetic than infinite loop!

                                        L 1 Reply Last reply
                                        0
                                        • C Chris Trelawny Ross

                                          Luc Pattyn wrote:

                                          eternal loop

                                          - so much more poetic than infinite loop!

                                          L Offline
                                          L Offline
                                          Luc Pattyn
                                          wrote on last edited by
                                          #20

                                          Poetry in motion. :-D

                                          Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum

                                          Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.

                                          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