When the debugger attaches to a running process, it may be attaching to as many as four types of code within the process — native, common language runtime, T-SQL, and script. You may recognize these as the Program Types you are asked to select in the Attach to Process dialog box. Sometimes the debugger can successfully attach to one program type, but not to another. This might happen, for example, if you try to attach to a process running on a remote machine that does not have the correct debugger components for all program types or if you try to attach to two processes for direct database debugging. (SQL debugging supports only one such process at a time.)
If the debugger fails to attach to all program types, it displays a message box with a message similar to this:
The requested attach was not completed successfully. Program types successfully attached are: Common Language Runtime Native (Win32) Microsoft T_SQL Program types that failed to attach are: Script
If the debugger successfully attaches to even one program type, it is successfully attached to the process. That means you can click OK in the message box and proceed to debug the process. However, you will not be able to debug any code within the process whose program type was not successfully attached. If you received the message shown above, for example, you would not be able to debug script code within the process. Script would still run within the process, but you would not be able to set breakpoints, view data, or perform other debugging operations in the Script.
To obtain specific information about why a program type failed to attach
- Detach from the process.
- In the Processes dialog box, select the partially attached process in the Debugged Processes list.
- Click the Detach button.
- Reattach to the process, selecting only a single program type.
- In the Processes dialog box, select the process in the Available Processes list.
- Click the Attach button.
- In the Attach to Processes dialog box, select only the program type that failed to attach.
- Click OK.
You should now get another message box with a specific error message.
Attaching to Managed Code
Note For the debugger to attach to code written in Managed Extensions for C++, the code needs to emit DebuggableAttribute. You can add this to your code automatically by linking with the /ASSEMBLYDEBUG linker option.