VBnet 2008 & 2010 skipping lines

bakemonoshi

New member
Joined
Jul 6, 2010
Messages
3
Programming Experience
3-5
Hey guys i have a very anoying issue regarding the fact that sometimes, when VS2008 or 2010 finds an error along my code, it just skips it, no warnings or errors reported, then it runs on debug mode, without all the lines that are after the ones that dont work in each function that contains an error, on release it dosen't run at all. Can you guys please get me out of this one? It never happened before so i suspect i may have meddled with VS's configurations unknowingly!? Thank you in advance. Here goes an example.

VB.NET:
Imports MTV3D65
Public Class Form1
    Declare Function GetFocus Lib "user32" () As Integer

    Private tv As TVEngine
    Private repeat As Boolean

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        tv = New TVEngine ' the error occurs here, and if i add a breakpoint here, it doesn't stop at it.

        tv.Init3DWindowed(PictureBox1.Handle)
        repeat = True
        Show()
        LifeLoop() ' this dosen't even run
    End Sub

    Private Sub LifeLoop()
        While repeat
            If GetFocus = Me.Handle.ToInt32 Then
                tv.Clear(False)
                tv.RenderToScreen()
                MsgBox("doin it")
            Else
                System.Threading.Thread.Sleep(100)
            End If
            Application.DoEvents()
        End While
        repeat = False 'nevermind these
        tv.ReleaseAll()
        tv = Nothing
        End
    End Sub
End Class

it displays the for as if no code has run at all.
the problem is not on the library im using. I SWEAR! ty
 
Last edited:
Are you running Vista x64 or Win7 x64? This is a known bug with .Net & x64 OS's that the Load event in forms doesn't receive any exceptions. The x64 team at MS (it's an operating system thing, not .Net) has openly stated in the MSDN forum that they know about the issue and the bug exists by x64 design and therefor they will not do anything about it.

It seems to be only winforms and the form's load event, I don't know if it exists in wpf windows or not.

Your form load event does run, set a break point at the top of the sub (the line that says 'private') and you'll see it break on that line and you can step through it line by line, it's just that it'll ignore any exceptions your code can raise in that event. You can probably move most of it to the Shown event (which fires right after the form shows on the screen) and be fine.
 
It's not that exceptions are ignored. It's that they are implicitly caught. It's as though the contents of the Load event handler is wrapped in a Try block with an empty Catch block. All you have to do is explicitly wrap it in a Try block and then provide a non-empty Catch block.
 
Back
Top