VB6 Crash when stepping through code |
Post Reply |
Author | |
corpcon
Groupie Joined: 28 June 2007 Status: Offline Points: 70 |
Post Options
Thanks(0)
Posted: 26 May 2008 at 12:04am |
Ever since I've been using this product (latest version), VB6 will occassionally crash on me when I stop at a breakpoint and step through some code. It always happens with the same code segments throughout the app, but not at other segments. It's definitely not the code that is causing the crash.
Anyone else experience this?
|
|
joeliner
Senior Member Joined: 09 June 2006 Status: Offline Points: 273 |
Post Options
Thanks(0)
|
I have been experiencing similar problems esp. when i stop at a breakpoint and try to step through the code, VB6 crushes. on my case it doesnt happen with the same code segments;quite hard to pin down the cause of this. :(
On my side i only experience this problem when i apply VB6 SP6. what service pack are you using? |
|
corpcon
Groupie Joined: 28 June 2007 Status: Offline Points: 70 |
Post Options
Thanks(0)
|
VB6 SP6 on Vista
|
|
corpcon
Groupie Joined: 28 June 2007 Status: Offline Points: 70 |
Post Options
Thanks(0)
|
In one instance, I have discovered that it will crash VB if there is a break in a segment of code that executes when the form loads, but if I add the break later on, at that same point, it doesn't crash VB.
I'm using Skin Framework and a few CJ controls on these forms.
This really sucks.
|
|
JasonG
Groupie Joined: 07 July 2008 Status: Offline Points: 76 |
Post Options
Thanks(0)
|
I have a similar issue, however my crash takes place when I end the program (by clicking the VB stop button - the form close button minimizes the app).
VB6 SP6 Vista. |
|
Product: Xtreme SuitePro (ActiveX) 12.0.1
Platform: Windows Vista/XP Language: Visual Basic 6.0 SP6 |
|
Baldur
Senior Member Joined: 22 November 2006 Location: Germany Status: Offline Points: 244 |
Post Options
Thanks(0)
|
To prevent the crash for debug, you can't use skinning.
I have solved this with a command-option "-skin" that i checked in Command$.
So i disable skinning and also set ApplyNewThreads and ApplyNewWindows to false, the ide don't crash.
see also here:
|
|
jpbro
Senior Member Joined: 12 January 2007 Status: Offline Points: 1355 |
Post Options
Thanks(0)
|
Alternately, you could just apply the skin if you are not running in the IDE, so:
|
|
Product: Xtreme SuitePro (ActiveX) version 16.2.6
Platform: Windows XP - SP3 Language: Visual Basic 6.0 SP6 |
|
corpcon
Groupie Joined: 28 June 2007 Status: Offline Points: 70 |
Post Options
Thanks(0)
|
Thank you VERY much for that work-around
|
|
Oleg
Admin Group Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
Post Options
Thanks(0)
|
Nice 1 / 0 trick. Didn't know it :-)
|
|
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS |
|
jpbro
Senior Member Joined: 12 January 2007 Status: Offline Points: 1355 |
Post Options
Thanks(0)
|
Glad to be of service, and it is a nice trick. I can't take credit for inventing it though...I'm not 100% sure who did discover this trick. I got it from some code by Olaf Schmidt at http://www.thecommon.net/2.html.
I see Google Groups posts as far back as 1999 using the trick, but I havent found anyone claiming to have discovered it. |
|
Product: Xtreme SuitePro (ActiveX) version 16.2.6
Platform: Windows XP - SP3 Language: Visual Basic 6.0 SP6 |
|
jpbro
Senior Member Joined: 12 January 2007 Status: Offline Points: 1355 |
Post Options
Thanks(0)
|
I should also add that I have read that the Debug object calls are only ignored at compiled run-time if they don't also include Subroutine calls...Hence Debug.Print 1/0 will no be compiled, but Debug.Print SomeFunction(1/0) will. I haven't tested this myself though.
|
|
Product: Xtreme SuitePro (ActiveX) version 16.2.6
Platform: Windows XP - SP3 Language: Visual Basic 6.0 SP6 |
|
JasonG
Groupie Joined: 07 July 2008 Status: Offline Points: 76 |
Post Options
Thanks(0)
|
I posted this function on PlanetSourceCode back in 2002.
I couldnt tell you where I got it from. http://pscode.com/vb/scripts/ShowCode.asp?txtCodeId=30524&lngWId=1 Also, as one of the commenters points out, you can also use x = ambient.usermode |
|
Product: Xtreme SuitePro (ActiveX) 12.0.1
Platform: Windows Vista/XP Language: Visual Basic 6.0 SP6 |
|
jpbro
Senior Member Joined: 12 January 2007 Status: Offline Points: 1355 |
Post Options
Thanks(0)
|
I've had trouble with Ambient.Usermode raising errors under certain circumstances (can't remember which), so I've been avoiding it for a while...
In my search for the oldest reference to Debug.Print 1/0, I've also found this method for determining compiled run-time that might be superior as it does not affect the Error object (and doesn't require error handling):
Source: http://visualbasic.about.com/od/usevb6/l/blfaq0012a.htm Downside would be the the public variable I guess, although this makes step debugging cleaner. |
|
Product: Xtreme SuitePro (ActiveX) version 16.2.6
Platform: Windows XP - SP3 Language: Visual Basic 6.0 SP6 |
|
jpbro
Senior Member Joined: 12 January 2007 Status: Offline Points: 1355 |
Post Options
Thanks(0)
|
Actually, it seems that Ambient.UserMode doesn't quite do the trick on a couple of fronts...
1) It's only available to a UserControl (AFAIK) 2) It returns TRUE at runtime whether or not the program has been compiled. The supplied IsRunningInIde function returns TRUE when run-time is invoked from the IDE, but FALSE if running from a compiled EXE. The Debug.Print / Debug.Assert methods have their own value over Ambient.UserMode unless I am missing something. |
|
Product: Xtreme SuitePro (ActiveX) version 16.2.6
Platform: Windows XP - SP3 Language: Visual Basic 6.0 SP6 |
|
JasonG
Groupie Joined: 07 July 2008 Status: Offline Points: 76 |
Post Options
Thanks(0)
|
and back to the original topic of this post, I've removed IDE Skinning, and am STILL getting a crash. Must have to do with my CommandBar array or something.
|
|
Product: Xtreme SuitePro (ActiveX) 12.0.1
Platform: Windows Vista/XP Language: Visual Basic 6.0 SP6 |
|
jpbro
Senior Member Joined: 12 January 2007 Status: Offline Points: 1355 |
Post Options
Thanks(0)
|
Clicking the Stop button is often a deadly way to end your program...My understanding is that it just halts everything and doesn't release memory, clean-up objects, etc...(kind of like calling END in your code...bad idea).
If you are using QueryUnload to catch the window closing, and minimizing instead, maybe you should disable that while in the IDE...Something like:
That way you can still close the program by clicking the X button while coding/debugging, but when compiled, clicking the X button will minimize the form. |
|
Product: Xtreme SuitePro (ActiveX) version 16.2.6
Platform: Windows XP - SP3 Language: Visual Basic 6.0 SP6 |
|
JasonG
Groupie Joined: 07 July 2008 Status: Offline Points: 76 |
Post Options
Thanks(0)
|
Actually, I've removed the code that minimizes on queryunload. I have been using the X, and it still yields the crash. it seems to only happen once my array counter has reached 1 (two sets of commandbars / tabcontrolpages). If I limit the tabcount to 0, everything is fine.
|
|
Product: Xtreme SuitePro (ActiveX) 12.0.1
Platform: Windows Vista/XP Language: Visual Basic 6.0 SP6 |
|
corpcon
Groupie Joined: 28 June 2007 Status: Offline Points: 70 |
Post Options
Thanks(0)
|
Yea, I use Debug.Assert 1 / 0. I think I got it from VBPJ in the mid 90's (but it might have been Debug.Print back then). Don't know where I'd be without that little gem. Keep it simple and just use a function call as needed (we all have our own little methods and quirks of doing things) ...
Function util_bInDesignMode() As Boolean
On Error GoTo DesignModeError Debug.Assert 1 / 0 ' When compiled into an exe, the Assert method is omitted util_bInDesignMode = False ' Readability ... Not really necessary Exit Function
DesignModeError: util_bInDesignMode = True End Function |
|
jpbro
Senior Member Joined: 12 January 2007 Status: Offline Points: 1355 |
Post Options
Thanks(0)
|
JasonG - Any chance of a sample that consistently crashes? I've had my IDE crash occasionally (not limited to when using CJ controls, but it happens frequently enough in Vista). I haven't had it crash in a consistently reproducable way though. Sometimes it crashes when using the scrollbars, sometimes when commenting lines...
If you have a sample that crashes consistently, it could be useful for tracking down the problem. |
|
Product: Xtreme SuitePro (ActiveX) version 16.2.6
Platform: Windows XP - SP3 Language: Visual Basic 6.0 SP6 |
|
JasonG
Groupie Joined: 07 July 2008 Status: Offline Points: 76 |
Post Options
Thanks(0)
|
I would LOVE to provide a sample, however I would really need to create a new project as the software im writing is 'confidential'... let me work on that for you (for me).
Thanks! |
|
Product: Xtreme SuitePro (ActiveX) 12.0.1
Platform: Windows Vista/XP Language: Visual Basic 6.0 SP6 |
|
jpbro
Senior Member Joined: 12 January 2007 Status: Offline Points: 1355 |
Post Options
Thanks(0)
|
No problem Jason, I understand the confidentiality requirement. Unfortunately the larger more complex programs tend to exhibit bad behaviours, and then trying to reproduce the problem in a small sample can be tricky! Hopefully you can reproduce it in a smaller sample so we can get to the bottom of it. Also, I've found that sometimes the act of trying to reproduce the problem yields the solution.
Just a thought - The only time I've consistently had the IDE crash at program termination is when I've been subclassing and been sloppy (forgetting to restore the old wndproc or something). Are you subclassing anything in your app? |
|
Product: Xtreme SuitePro (ActiveX) version 16.2.6
Platform: Windows XP - SP3 Language: Visual Basic 6.0 SP6 |
|
JasonG
Groupie Joined: 07 July 2008 Status: Offline Points: 76 |
Post Options
Thanks(0)
|
Negative. This seems to DIRECTLY connected to my array of commandbars and/or tabs.
I will have a (non) working sample for you first thing in the A.M. |
|
Product: Xtreme SuitePro (ActiveX) 12.0.1
Platform: Windows Vista/XP Language: Visual Basic 6.0 SP6 |
|
JasonG
Groupie Joined: 07 July 2008 Status: Offline Points: 76 |
Post Options
Thanks(0)
|
Ok, here is my (non) working sample code.
http://www.jasongoldberg.com/files/sample.zip Please let me know if you have any troubles running it. I tried to remove all extra references. Here is how to get it to crash (actually, to freeze) the VB IDE. 1. Run the program, and close it. Notice it closes without a problem. 2. Run the program, click the "+" tab to open a new message, close the program. Again it closes without a problem. 3. Run the program, click the "+" tab TWICE to open two new messages. Close the program - the VB IDE freezes (both on my Vista environment as well as a co-worker's XP environment). Thanks for taking a look guys! |
|
Product: Xtreme SuitePro (ActiveX) 12.0.1
Platform: Windows Vista/XP Language: Visual Basic 6.0 SP6 |
|
jpbro
Senior Member Joined: 12 January 2007 Status: Offline Points: 1355 |
Post Options
Thanks(0)
|
Hi Jason,
Well, I was able to reproduce the crash and find a (temporary?) solution. I say temporary because I'm not sure why it fixes the problem. Try this: 1) Open the project and draw a PictureBox on frmMessages2 2) Select the TabControlPage(0) control and the press Ctrl+X to cut it from the form 3) Select the PictureBox you created in Step 1, and then press Ctrl+V to paste it into the PictureBox 4) Change the Visible property of the PictureBox to False 5) Run the Program, add 2 (or more) PinkNotes(r), and then close the program. It shouldn't crash the IDE anymore (it doesn't on my computer). As to exactly why this helps, I can't say! I was trying to move your TabControls to UserControls to see if that would help, and I made some progress, but I had to cut out some large swaths of your code to get it to run without crashing. I then tried to just plonk the TabControlPage into a PictureBox without modifying code and it worked... |
|
Product: Xtreme SuitePro (ActiveX) version 16.2.6
Platform: Windows XP - SP3 Language: Visual Basic 6.0 SP6 |
|
JasonG
Groupie Joined: 07 July 2008 Status: Offline Points: 76 |
Post Options
Thanks(0)
|
I have to admit when I read your post, I thought "No way" - but it worked.
I don't know why and I dont know how, but it really did. Outstanding!! Im going to have to investigate this further. Thanks a ba-zillion. |
|
Product: Xtreme SuitePro (ActiveX) 12.0.1
Platform: Windows Vista/XP Language: Visual Basic 6.0 SP6 |
|
jpbro
Senior Member Joined: 12 January 2007 Status: Offline Points: 1355 |
Post Options
Thanks(0)
|
Glad to help, and sorry I can't offer any good explanation for the behaviour...Mystery fixes aren't terribly satisfying, but sometimes necessary (at least in the short term).
|
|
Product: Xtreme SuitePro (ActiveX) version 16.2.6
Platform: Windows XP - SP3 Language: Visual Basic 6.0 SP6 |
|
JasonG
Groupie Joined: 07 July 2008 Status: Offline Points: 76 |
Post Options
Thanks(0)
|
Satisfying enough for now. When deadlines are involved, I dont really need to know all the ins and outs :) Thanks again.
|
|
Product: Xtreme SuitePro (ActiveX) 12.0.1
Platform: Windows Vista/XP Language: Visual Basic 6.0 SP6 |
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |