Click here to Skip to main content
15,896,557 members
Articles / Programming Languages / Visual Basic

Debugging .NET Framework and MS Visual Studio Managed Classes at Run time and Design time

Rate me:
Please Sign up or sign in to vote.
4.93/5 (29 votes)
11 Nov 20039 min read 262.4K   917   69  
This article explains how it is possible to seamlessly set breakpoints, step into, set watches and examine local variables for .NET framework classes as well as any other managed assemblies.
Imports System
Imports System.Windows.Forms

Imports System.ComponentModel

Imports System.Data.OleDb
Imports System.Data

Imports System.ComponentModel.Design
Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Drawing.Design
Imports System.Diagnostics
Imports System.Windows.Forms.ComponentModel
Imports System.Windows.Forms.Design
Imports System.ComponentModel.Design.Serialization

Public Class TestCtlDesigner
	Inherits System.Windows.Forms.Design.ScrollableControlDesigner


	Public Overrides Sub Initialize(ByVal component As System.ComponentModel.IComponent)
		MyBase.Initialize(component)

		Call Me.InitHandlers()

	End Sub

	Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
		''
		Call Me.RemoveHandlers()
		'
		MyBase.Dispose(disposing)
	End Sub

	Protected Overridable Sub InitHandlers()
		AddHandler Me.SelectionService.SelectionChanged, AddressOf Me.HandleSelectionChanged
	End Sub

	Protected Overridable Sub RemoveHandlers()
		RemoveHandler Me.SelectionService.SelectionChanged, AddressOf Me.HandleSelectionChanged
	End Sub

	Public ReadOnly Property SelectionService() As ISelectionService
		Get
			Return CType(Me.GetService(GetType(ISelectionService)), ISelectionService)
		End Get
	End Property

	Public Sub HandleSelectionChanged(ByVal sender As Object, ByVal e As System.EventArgs)
		Dim colComp As ICollection
		Dim comp As Component

		colComp = Me.SelectionService.GetSelectedComponents

		For Each comp In colComp
			If Not comp.Site Is Nothing Then
				Debug.WriteLine("   " & comp.Site.Name)
			End If
		Next

	End Sub

	Protected Overrides Property DrawGrid() As Boolean
		Get
			Return False
		End Get
		Set(ByVal Value As Boolean)
			''
		End Set
	End Property
End Class

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
India India
Sumeet is the main architect of Copernicus, a Hospital Information System owned by Eutech Cybernetics and loves development, esp. in Visual Basic .Net as it removes so many of the limitations that were so frustrating in VB6.

He practiced as a General Surgeon for many years in India before finding his real passion was software development. Sumeet stays in Pondicherry, a small town just south of Chennai, in India, as he loves its peaceful and very special atmosphere

Comments and Discussions