How to: Deal With Attach Errors
This topic applies to:
Pro and Team
Does not apply
Command or commands hidden by default.
When the Visual Studio debugger attaches to a running process, the process can contain one or more types of code. The code types the debugger can attach to are native, managed, T-SQL, and script. These code types are displayed and selected in the Attach to Process dialog box.
For the debugger to attach to managed code written in C++, the code must emit DebuggableAttribute. You can add this to your code automatically by linking with the /ASSEMBLYDEBUG linker option.
Sometimes, the debugger can successfully attach to one code type, but not to another code type. This might occur if you are trying to attach to a process that is running on a remote computer. The remote computer might have remote debugging components installed for some code types but not for others. It can also occur if you try to attach to two or more processes for direct database debugging. SQL debugging supports attaching to a single process only.
If the debugger is able to attach to some, but not all, code types, you will see 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 at least one code type, you can proceed to debug the process. You will be able to debug only the code types that were successfully attached. The preceding example message shows that the script code type failed to attach. Therefore, you would not be able to debug script code within the process. The script code in the process would still run, but you would not be able to set breakpoints, view data, or perform other debugging operations in the Script.
If you want more specific information about why the debugger failed to attach to a code type, you can try to reattach to only that code type.
To obtain specific information about why a code type failed to attach
Detach from the process. To do so, on the Debug menu, click Detach All.
Reattach to the process, selecting only a single program type.
In the Attach to Process dialog box, select the process in the Available Processes list.
In the Select Code Type dialog box, select Debug these code types and the code type that failed to attach. Clear any other code.
Click OK. The Select Code Type dialog box closes.
In the Attach to Process dialog box, click Attach.
This time, the attach will fail completely, and you will get a specific error message.