Share via


How to: Deal With Attach Errors

This topic applies to:

Edition

Visual Basic

C#

C++

Web Developer

Express

Topic does not apply Topic does not apply Topic does not apply Topic does not apply

Standard

Topic applies Topic applies

Topic applies

Topic applies

Pro and Team

Topic applies Topic applies

Topic applies

Topic applies

Table legend:

Topic applies

Applies

Topic does not apply

Does not apply

Topic applies but command hidden by default

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.

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 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

  1. Detach from the process. To do so, on the Debug menu, click Detach All.

  2. Reattach to the process, selecting only a single program type.

    1. In the Attach to Process dialog box, select the process in the Available Processes list.

    2. Click Select.

    3. In the Select Code Type dialog box, select Debug these code types and the code type that failed to attach. Clear any other code.

    4. Click OK. The Select Code Type dialog box closes.

    5. In the Attach to Process dialog box, click Attach.

    This time, the attach will fail completely, and you will get a specific error message.

See Also

Other Resources

Attaching to Running Processes