QuickBooksDev Posted September 20, 2011 Posted September 20, 2011 We have not added any code to instantiate it. In a working program that uses the same technique. I hit F8 to step thru. 1. It goes into some CheckChanged events on frmMain so I assume the form is instantiated. 2. It then goes into the module with Public FormMain as frmMain = frmMain where it completes the definitions ok (does the last). 3. Then it goes to frmMain's MyBase.load 4. Program runs fine In the failing program I hit F8 1. It immediately goes to the module with Public FormMain as frmMain = frmMain (frmMain probably NOT instantiated) 2. The module definitions do not complete (last statement executed is the FormMain). 3. It goes to other modules for defintitions 4. It now goes to the ..Changed events on frmMain (on working programs this was first). 5. It then goes to the frmMain MyBase.load So the failing program is taking a different startup path and I do not know why. What would cause the modules to be executed first before frmMain is instantiated????? Quote
Leaders snarfblam Posted September 20, 2011 Leaders Posted September 20, 2011 One thing worth noting is that when you have declarations with initializers (such as Public FormMain as frmMain = frmMain), even though you don't write the code in the Sub New (i.e. the class constructor or type initializer), when the program is compiled, that is where it ends up, so an error on a field initializer can result in a type initializer exception. What you really need to do is catch the exception right off the bat. For some reason, the originating exception is not being caught, and you're getting the resulting type initializer exception. If nothing else works out, you should be able to see the original exception in the InnerException property of the type initiailizer exception, which should include a stack trace. It would help to set VS to break when any exception is thrown. If you go to "Exceptions" under the "Debug" menu, in the dialog that appears there are two columns of checkboxes. By default only "User-unhandled" is checked. Try checking the "Thrown" box as well. (You can probably leave "Managed Debugging Assistants" alone). Hopefully that will get VS to show you the root cause of the problem. Quote [sIGPIC]e[/sIGPIC]
QuickBooksDev Posted September 20, 2011 Author Posted September 20, 2011 We will try to debug change to see where it gets the error but I have a workaround now. We took out the = frmMain from the module and moved it to frmMain itself. That seemed to solve that part. We are now debugging other VB6 conversion issues. Thanks Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.