Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

How to: Attach to Managed Device Processes 

You attach to a process on a device in much the same way as you would on the desktop, except that you must set a registry key on the device to enable managed debugging if the process is already running without the debugger. The setting of this key persists until you change it, or, in the case of an emulator, until the emulator is closed without saving its settings.

NoteNote

Setting the device debug key reduces performance. When you are not debugging, reset the key.

An error message appears if you try to attach two debuggers or try to attach with a managed debugger when the device registry key has not been set.

You can start a process in several ways, including File Explorer, the command line, and so on. In the following step, you start the process by launching from the Debug menu. You can also start a process without the managed debugger, and then attach it later.

If you are targeting a Windows CE platform generated from Platform Builder, you need to have the toolhelp.dll library to populate the Available Processes pane. This library is included in the Windows Mobile SDKs.

NoteNote

The dialog boxes and menu commands you see might differ from those described in Help depending on your active settings or edition. To change your settings, choose Import and Export Settings on the Tools menu. For more information, see Visual Studio Settings.

Debug a Managed Process

To debug a managed process

  • On the Debug menu, click Start.

    NoteNote

    If you detach from processes started from the Debug menu, you cannot reattach without performing the following steps for attaching after a process is running. That is, the registry key on the device has to be set.

Attach to an Already Running Managed Process

If you plan to attach to a process that is already running, by, for example, clicking Start Without Debugging and then attaching to a running managed process, you must first set the device registry key before the process starts and before you try to attach using the Attach to Process dialog box. The following steps detail the process.

To set the device registry key to enable attaching to a running process

  1. On the Windows Start menu, point to All Programs, point to Microsoft Visual Studio 2005, point to Visual Studio Tools, and then click Remote Registry Editor.

  2. Using the Remote Registry Editor, connect to the device.

  3. Navigate to or create the following key: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETCompactFramework\Managed Debugger

  4. Set or create a DWORD value named AttachEnabled.

  5. Set the data for the value at 1.

    NoteNote

    Setting the device debug key significantly reduces performance. When you are not debugging, disable managed attach by resetting the data value to 0 or deleting the AttachEnabled value.

  6. Close the Remote Registry Editor.

    Managed attach is now enabled, and you will be able to start a process without the debugger and then attach to the process using the Attach to Process dialog box.

To attach to a managed process after the process is running

  1. After setting the registry key as described in the preceding steps, start a process without the debugger.

  2. On the Tools menu, click Attach to Process.

  3. In the Transport box, click Smart Device.

  4. In the Qualifier box, click Browse.

    NoteNote

    The Qualifier box is prepopulated with the most recently used devices from the current session.

  5. In the Connect to Device dialog box, select the platform, select the device, and then click Connect.

  6. In the Available Processes pane, select one or more processes to attach to, and then click Attach.

    NoteNote

    By default, code type is set automatically to Managed (.NET Compact Framework) if available, otherwise to Native (Smart Device). To override the default settings, click Select to open the Select Code Type dialog box. Note that you cannot select both.

    NoteNote

    Interop debugging is not supported. That is, you cannot debug both managed and native code types at the same time.

Detach From or Terminate a Process

To detach from or terminate a process

  1. On the Debug menu, point to Windows, and then click Processes.

  2. In the Processes window, right-click the process you want to detach from or terminate.

  3. On the shortcut menu, click Terminate Process or Detach from Process.

    NoteNote

    You can reopen the Attach to Process dialog box from this same shortcut menu.

Populate the Available Processes Pane

To populate the Available Processes pane in Windows CE projects

  • Include the file toolhelp.dll in the Windows CE OS image.

    —or—

    Manually copy the file toolhelp.dll to the target device.

See Also

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

Show:
© 2014 Microsoft