How to: Deal With Attach Errors
This topic applies to:
Edition |
Visual Basic |
C# |
F# |
C++ |
Web Developer |
---|---|---|---|---|---|
Express |
|||||
Pro, Premium, and Ultimate |
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 include native, managed, SQL, and script. These code types are displayed and selected in the Attach to Process dialog box.
Note
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 identifying which types failed to attach.
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.
Click Select.
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.