VB.NET IDE Debugger exits on "Exit Sub"

Go To StackoverFlow.com


In a current project, I have two applications that do essentially the same things. In the first application's UI, I developed a class that inherits a TreeView control. I used the OwnerDrawsAll value of the DrawMode property, and customized the appearance of the TreeView. In app 1, it works great, and I couldn't be more pleased. I haven't had a problem with it for a couple of months, and have used it frequently in that time.

In the second application, I have to make the same modifications, so I am employing the same custom TreeView class. In app 2, during the first opportunity that the TreeView enters the DrawNode event everything works fine until I get to the "Exit Sub" line of my DrawMode event handler. If I attempt to step through it, the app completely crashes without warning. Because it happens on the "Exit Sub" statement, I can't include it in a Try/Catch. The statement that instigates the DrawNode event is enclosed in a Try/Catch block, but it's not getting caught.

I have commented out all the functionality in my DrawNode event handler with the same result. Code included below:

Public Class TabularTreeView
    Inherits System.Windows.Forms.TreeView

Private Sub DrawMyNode(ByVal sender As Object, ByVal e As System.Windows.Forms.DrawTreeNodeEventArgs) Handles MyBase.DrawNode

        'Draw the node as default
        e.DrawDefault = True

        '...commented out and still fails....

    Catch ex As Exception
    End Try

End Sub   '<---this statement is where the debugger fails!

End Class

There are two differences in these applications. App 1 is a program, compiled to x86 as the target platform. App 2 is an Add-In for a program called SolidWorks, and is thus a .dll, compiled target platform is AnyCPU. The custom TreeView class is in a library compiled for AnyCPU.

Please help! I don't want to lose the work that's been done thus far!


2012-04-03 19:56
by Superhuman
Unless I'm missing something I believe you mean "End Sub". "Exit Sub" has a different meaning than "End Sub"... and your provided source does not include any "Exit Sub" statement - Sam Axe 2012-04-03 20:02
Document the content of the Output window - Hans Passant 2012-04-03 20:40


I noticed this behaviour also. Fixed it in my case by replacing Exit Sub by Return

2013-06-06 09:29
by JMan