Friday, January 7, 2011

Attaching debugger to .NET Compact Framework on mobile device (or emulator)

How to attach debugger to .NET Compact Framework running on the mobile device emulator

Enable Managed debugging on the mobile device - by default it is disabled to not affect performance.

Run Visual Studio Remote Tools> Remote Registry Editor and choose the Mobile Device/Emulator

Add/Change following key in registry

Go to the :
HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/.NETCompactFramework/Managed Debugger/ and set the AttachEnabled value to 1

if the 'Managed Debugger' key does not exist just create it, the same with AttachEnabled value (new DWORD Value with name: AttachEnabled and value: 1)

In the Visual Studio go to Debug > Attach to Process
In the Transport choose Smart Device
Browse for your Device/Emulator
Choose the application and attach debugger ( if an application have been opended before making changes in the Device Registry you may have to restart the application )

Right now (if the symbols are loaded) you can start debugging application. Voila!

Eclipse conditional breakpoints

Here is how to set a conditional breakpoint in Eclipse IDE:

1) on the Debug perspective go to Breakpoints view
2) Right-click the breakpoint and choose "Breakpoint properties" (or select the breakpoint and press Alt+Enter)
3) On the properties window enable checkbox "Enable condition" and type a condition expression, breakpoint can be hit when condition becomes true or the condition value changes-it is all configurable.

That's all, although setting conditional breakpoint is not as intuitive as in Visual Studio, it works and does the job!