I have a huge VB6 legacy program that I just converted to VB.net. The main forms display on the screen, and I successfully print a comment on the last executable line before entering the Windows Message Loop.
Then the program dies (all windows disappear) with no indication of what went wrong.
I have been unable to determine what code is executing when this program aborts, and would appreciate ideas.
I am running in Visual Studio 2008 Professional (since the code was just converted from VB6), using the debugger.
I have added a method call as the first line in every timer_Tick handler and every form_Activated handler. I also do the same call in many major functions. There is a Breakpoint set in the first line of the sub that I call... and it is not hit after the message loop starts.
I have attempted to look at all Windows messages, but am not familiar with the Spy++ tool, and am totally swamped with messages. I know I can limit to a particular window, by my program opens MANY windows, and it could be a new one trying to open that causes the failure.
If I don't get other solutions, I can further research using Spy++, but I'd really like to get OTHER suggestions on finding the location.
Thanks.
Without code, this is a guess but it would match what you describe is happening. When an app starts from Sub Main
, your code has to start the message pump - it is not something that happens automatically:
Public Sub Main()
...
' same as `Enable XP Visual Styles in App settings
Application.EnableVisualStyles()
...
' last line
Application.Run(New MainForm())
End Sub
If you want to use Visual Styles, they need to be enabled before any form or control is referenced.
The message pump is started via Application.Run
. If you simply show your starting form (and/or others), the app will terminate when Sub Main
terminates because there is no app message pump.