Enable Remote Debugging on NETCF apps

Published 14 May 08 09:48 AM | lokeuei 

Thanks to Jon Box for figuring out this problem. This is taken from David Kline's blog but still applies to LAB03. when you want to attach to the running SMS interception process.

By default, support for attaching the debugger to a .NET Compact Framework application is disabled in NetCF v2.  This is done to optimize the runtime performance of the application on the device.  When attach to process support is enabled, the Just-In-Time compiler generates debuggable code.  Debuggable code is larger (to accommodate breakpoints, some optimizations will be disabled) and as a consequence runs slower.  Since all NetCF debugging is remote debugging, communications transports are also loaded, which increases the application's working set.

It is important to remember that attach to process support is a device global setting and that every application that runs on NetCF v2 will be run in attachable / debuggable mode.  Because of this, I highly recommend enabling attach to process support only when you required and disabling it once you are finished debugging.

To ensure that the transports are properly installed on the device, I recommend deploying / debugging your application once using F5.

Enabling attach to process support
Attach to process support can be enabled (and disabled) using the Remote Registry Editor that is installed by Visual Studio 2005 Beta 2.

WARNING: Using Remote Registry Editor incorrectly can cause serious problems that may require you to hard reset your device. Microsoft cannot guarantee that problems resulting from the incorrect use of Remote Registry Editor can be solved. Use Remote Registry Editor at your own risk.

  1. Start the Remote Registry Editor
    • Open the Start menu
    • Select All Programs
    • Select Microsoft Visual Studio 2005 Beta 2
    • Select Visual Studio Remote Tools
    • Select Remote Registry Editor
  2. Connect to your device
    • On the Target menu, select Connect
    • Select your device
    • Click OK
  3. Enable attach to process support
    • In the left hand pane, expand the device
    • Expand HKEY_LOCAL_MACHINE
    • Expand SOFTWARE
    • Expand Microsoft
    • Expand .NETCompactFramework
    • Expand Managed Debugger
      If this key does not exist, you will need to create it
      • Right click on .NETCompactFramework
      • Select New > Key
      • Type "Managed Debugger" (without quotes)
      • Click Ok
    • Set the value of AttachEnabled to 1
      If this value does not exist, you will need to create it
      • Right click on Managed Debugger
      • Select New > DWORD Value
      • Set the Name to AttachEnabled
      • Set the value to 1
      • Click OK

To disable attach to process support, follow the above steps and either delete the AttachEnabled value or set it to 0.

If you have Visual Studio 2005 Beta 2 installed, you can now start your applications without debugging support (ex: Ctrl+F5) and then attach to the process while it is running.  I will discuss this more in future posts.

Filed under: , , ,

Comments

# Out Of The Box said on May 21, 2008 4:16 PM:

I enjoyed last week's class. Hosted at New Horizons and co-presented with Loke Uei Tan , we had a class

Anonymous comments are disabled

Search

This Blog

Syndication

Page view tracker