Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > ActiveX COM > Suite Pro
  New Posts New Posts RSS Feed - VB6 Crash when stepping through code
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

VB6 Crash when stepping through code

 Post Reply Post Reply
Author
Message
corpcon View Drop Down
Groupie
Groupie


Joined: 28 June 2007
Status: Offline
Points: 70
Post Options Post Options   Thanks (0) Thanks(0)   Quote corpcon Quote  Post ReplyReply Direct Link To This Post Topic: VB6 Crash when stepping through code
    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?
Back to Top
joeliner View Drop Down
Senior Member
Senior Member
Avatar

Joined: 09 June 2006
Status: Offline
Points: 273
Post Options Post Options   Thanks (0) Thanks(0)   Quote joeliner Quote  Post ReplyReply Direct Link To This Post Posted: 26 May 2008 at 1:16am
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?

Back to Top
corpcon View Drop Down
Groupie
Groupie


Joined: 28 June 2007
Status: Offline
Points: 70
Post Options Post Options   Thanks (0) Thanks(0)   Quote corpcon Quote  Post ReplyReply Direct Link To This Post Posted: 26 May 2008 at 11:56am
VB6 SP6 on Vista
Back to Top
corpcon View Drop Down
Groupie
Groupie


Joined: 28 June 2007
Status: Offline
Points: 70
Post Options Post Options   Thanks (0) Thanks(0)   Quote corpcon Quote  Post ReplyReply Direct Link To This Post Posted: 02 June 2008 at 12:31am
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.
Back to Top
JasonG View Drop Down
Groupie
Groupie


Joined: 07 July 2008
Status: Offline
Points: 76
Post Options Post Options   Thanks (0) Thanks(0)   Quote JasonG Quote  Post ReplyReply Direct Link To This Post Posted: 15 July 2008 at 8:41am
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
Back to Top
Baldur View Drop Down
Senior Member
Senior Member


Joined: 22 November 2006
Location: Germany
Status: Offline
Points: 244
Post Options Post Options   Thanks (0) Thanks(0)   Quote Baldur Quote  Post ReplyReply Direct Link To This Post Posted: 15 July 2008 at 1:36pm
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:
Back to Top
jpbro View Drop Down
Senior Member
Senior Member
Avatar

Joined: 12 January 2007
Status: Offline
Points: 1355
Post Options Post Options   Thanks (0) Thanks(0)   Quote jpbro Quote  Post ReplyReply Direct Link To This Post Posted: 15 July 2008 at 2:17pm
Alternately, you could just apply the skin if you are not running in the IDE, so:


Public Function IsRunningInIde() As Boolean
   Static called                                  As Boolean
   Static r                                       As Boolean

   If Not called Then
      called = True

      On Error Resume Next
      Debug.Print 1 / 0   ' Only raises error when running in IDE because Compiled Run-time ignores Debug object
      r = Err: Err.Clear
   End If

   IsRunningInIde = r
End Function

Private Sub Form_Load
    With MySkin
        If Not IsRunningInIde Then
             ' Runtime, so load skin
            .ExcludeModule "msado15.dll" ' ADO-Runtime
            .LoadSkin App.Path & "\..\Style\FTStyle.cjstyles", "normalblue.ini"
            .ApplyOptions = xtpSkinApplyMetrics Or xtpSkinApplyColors Or xtpSkinApplyFrame
       End If

        .AutoApplyNewThreads = Not IsRunningInIde
        .AutoApplyNewWindows = Not IsRunningInIde
    End With

End Sub

Product: Xtreme SuitePro (ActiveX) version 16.2.6
Platform: Windows XP - SP3

Language: Visual Basic 6.0 SP6

Back to Top
corpcon View Drop Down
Groupie
Groupie


Joined: 28 June 2007
Status: Offline
Points: 70
Post Options Post Options   Thanks (0) Thanks(0)   Quote corpcon Quote  Post ReplyReply Direct Link To This Post Posted: 15 July 2008 at 3:01pm
Thank you VERY much for that work-around
Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 15 July 2008 at 3:49pm
Nice 1 / 0  trick. Didn't know it :-)
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
jpbro View Drop Down
Senior Member
Senior Member
Avatar

Joined: 12 January 2007
Status: Offline
Points: 1355
Post Options Post Options   Thanks (0) Thanks(0)   Quote jpbro Quote  Post ReplyReply Direct Link To This Post Posted: 15 July 2008 at 3:57pm
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

Back to Top
jpbro View Drop Down
Senior Member
Senior Member
Avatar

Joined: 12 January 2007
Status: Offline
Points: 1355
Post Options Post Options   Thanks (0) Thanks(0)   Quote jpbro Quote  Post ReplyReply Direct Link To This Post Posted: 15 July 2008 at 3:59pm
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

Back to Top
JasonG View Drop Down
Groupie
Groupie


Joined: 07 July 2008
Status: Offline
Points: 76
Post Options Post Options   Thanks (0) Thanks(0)   Quote JasonG Quote  Post ReplyReply Direct Link To This Post Posted: 15 July 2008 at 4:00pm
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
Back to Top
jpbro View Drop Down
Senior Member
Senior Member
Avatar

Joined: 12 January 2007
Status: Offline
Points: 1355
Post Options Post Options   Thanks (0) Thanks(0)   Quote jpbro Quote  Post ReplyReply Direct Link To This Post Posted: 15 July 2008 at 4:09pm
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):


'You can check this flag anywhere in your code
Public IsIDE As Boolean
Private Sub Form_Load()
IsIDE = False
'This line is only executed if
'running in the IDE and then
'returns True
Debug.Assert CheckIDE
'Use the IsIDE flag anywhere
If IsIDE Then
MsgBox ("Running under IDE")
Else
MsgBox ("Running as EXE")
End If
End Sub

Private Function CheckIDE() As Boolean
'This function will never be executed in an EXE
IsIDE = True 'set global flag
'Set CheckIDE or the Debug.Assert will Break
CheckIDE = True
End Function


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

Back to Top
jpbro View Drop Down
Senior Member
Senior Member
Avatar

Joined: 12 January 2007
Status: Offline
Points: 1355
Post Options Post Options   Thanks (0) Thanks(0)   Quote jpbro Quote  Post ReplyReply Direct Link To This Post Posted: 15 July 2008 at 4:16pm
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

Back to Top
JasonG View Drop Down
Groupie
Groupie


Joined: 07 July 2008
Status: Offline
Points: 76
Post Options Post Options   Thanks (0) Thanks(0)   Quote JasonG Quote  Post ReplyReply Direct Link To This Post Posted: 15 July 2008 at 4:18pm
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
Back to Top
jpbro View Drop Down
Senior Member
Senior Member
Avatar

Joined: 12 January 2007
Status: Offline
Points: 1355
Post Options Post Options   Thanks (0) Thanks(0)   Quote jpbro Quote  Post ReplyReply Direct Link To This Post Posted: 15 July 2008 at 4:23pm
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:


Public Function IsRunningInIde() As Boolean
   Static called                                  As Boolean
   Static r                                       As Boolean

   If Not called Then
      called = True

      On Error Resume Next
      Debug.Print 1 / 0    ' Only raises error when running in IDE because Compiled Run-time ignores Debug object
      r = Err: Err.Clear
   End If

   IsRunningInIde = r
End Function

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
   If UnloadMode = vbFormControlMenu Then
      Cancel = Not IsRunningInIde
      Me.WindowState = vbMinimized
   End If
End Sub


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

Back to Top
JasonG View Drop Down
Groupie
Groupie


Joined: 07 July 2008
Status: Offline
Points: 76
Post Options Post Options   Thanks (0) Thanks(0)   Quote JasonG Quote  Post ReplyReply Direct Link To This Post Posted: 15 July 2008 at 4:28pm
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
Back to Top
corpcon View Drop Down
Groupie
Groupie


Joined: 28 June 2007
Status: Offline
Points: 70
Post Options Post Options   Thanks (0) Thanks(0)   Quote corpcon Quote  Post ReplyReply Direct Link To This Post Posted: 15 July 2008 at 4:28pm
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
Back to Top
jpbro View Drop Down
Senior Member
Senior Member
Avatar

Joined: 12 January 2007
Status: Offline
Points: 1355
Post Options Post Options   Thanks (0) Thanks(0)   Quote jpbro Quote  Post ReplyReply Direct Link To This Post Posted: 15 July 2008 at 4:32pm
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

Back to Top
JasonG View Drop Down
Groupie
Groupie


Joined: 07 July 2008
Status: Offline
Points: 76
Post Options Post Options   Thanks (0) Thanks(0)   Quote JasonG Quote  Post ReplyReply Direct Link To This Post Posted: 15 July 2008 at 4:34pm
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
Back to Top
jpbro View Drop Down
Senior Member
Senior Member
Avatar

Joined: 12 January 2007
Status: Offline
Points: 1355
Post Options Post Options   Thanks (0) Thanks(0)   Quote jpbro Quote  Post ReplyReply Direct Link To This Post Posted: 15 July 2008 at 4:39pm
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

Back to Top
JasonG View Drop Down
Groupie
Groupie


Joined: 07 July 2008
Status: Offline
Points: 76
Post Options Post Options   Thanks (0) Thanks(0)   Quote JasonG Quote  Post ReplyReply Direct Link To This Post Posted: 15 July 2008 at 4:43pm
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
Back to Top
JasonG View Drop Down
Groupie
Groupie


Joined: 07 July 2008
Status: Offline
Points: 76
Post Options Post Options   Thanks (0) Thanks(0)   Quote JasonG Quote  Post ReplyReply Direct Link To This Post Posted: 16 July 2008 at 8:50am
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
Back to Top
jpbro View Drop Down
Senior Member
Senior Member
Avatar

Joined: 12 January 2007
Status: Offline
Points: 1355
Post Options Post Options   Thanks (0) Thanks(0)   Quote jpbro Quote  Post ReplyReply Direct Link To This Post Posted: 16 July 2008 at 10:55am
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

Back to Top
JasonG View Drop Down
Groupie
Groupie


Joined: 07 July 2008
Status: Offline
Points: 76
Post Options Post Options   Thanks (0) Thanks(0)   Quote JasonG Quote  Post ReplyReply Direct Link To This Post Posted: 16 July 2008 at 11:05am
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
Back to Top
jpbro View Drop Down
Senior Member
Senior Member
Avatar

Joined: 12 January 2007
Status: Offline
Points: 1355
Post Options Post Options   Thanks (0) Thanks(0)   Quote jpbro Quote  Post ReplyReply Direct Link To This Post Posted: 16 July 2008 at 12:52pm
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

Back to Top
JasonG View Drop Down
Groupie
Groupie


Joined: 07 July 2008
Status: Offline
Points: 76
Post Options Post Options   Thanks (0) Thanks(0)   Quote JasonG Quote  Post ReplyReply Direct Link To This Post Posted: 16 July 2008 at 1:04pm
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
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.203 seconds.