Debugging NetCF apps with cordbg - Part XI: VB.Net

For the most part, my posts are written in C#.  Of the NetCF supported languages, C# is where I am most comfortable.  Every once in awhile, however, I'll post a VB.Net related topic (this is my second).  Today I thought I'd show a NetCF application written in VB.Net running under cordbg.

Debugging VB.Net applications under cordbg works the same way as debugging C# applications.  Once you connect, you can view source, step, set breakpoints, etc.

Below is a brief source display of the Scribbler sample application from Visual Studio .NET 2003 (Program Files\Microsoft Visual Studio .NET 2003\CompactFrameworkSDK\v1.0.5000\Windows CE\Samples\VB\Pocket PC\Scribbler), after hitting a breakpoint in the bClear_Click method.

(cordbg) sh 10
148:
149:     End Sub
150:
151:     Public Shared Sub Main()
152:         Application.Run(New ScribblerForm())
153:     End Sub
154:
155: #End Region
156:
157:     Private Sub bClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bClear.Click
158:*        Me.graphics.FillRectangle(New SolidBrush(Color.White), 0, 0, Me.pDrawWindow.Size.Width, Me.pDrawWindow.Size.Height)
159:         Me.pDrawWindow.Invalidate()
160:     End Sub
161:
162:     Private Sub pDrawWindow_Paint(ByVal sender As System.Object, ByVal e As PaintEventArgs) Handles pDrawWindow.Paint
163:         e.Graphics.DrawImage(Me.bitmap, 0, 0)
164:     End Sub
165:
166:     Private Sub pDrawWindow_MouseDown(ByVal sender As System.Object, ByVal e As MouseEventArgs) Handles pDrawWindow.MouseDown
167:         Me.hasCapture = True
168:         Me.oldX = e.X

One thing to be aware of when debugging VB.Net code in cordbg: there is no concept of "Me".  The example below shows the variables that are in scope in the source display above (inside of bClear_Click).

(cordbg) p
this=(0x0004115c) <Scribbler.ScribblerForm>
sender=(0x00041a94) <System.Windows.Forms.Button>
e=(0x00042fb4) <System.EventArgs>
_Vb_t_record_1=<System.Drawing.Size>
_Vb_t_record_0=<System.Drawing.Size>
$thread=(0x000414e8) <System.Threading.Thread>

As you can see, there is no "Me" variable in the above list.  Instead, you get the C++/C# equivalent: "this".  In other words: "this" == "Me".  Sorry for the C/C++/C# style == operator in a VB.Net post, but I couldn't help myself.  ;)

Until next time,
-- DK

Disclaimer(s):
This posting is provided "AS IS" with no warranties, and confers no rights.