Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does it mean to attach to process in Visual Studio 2010?

Tags:

I have seen this option under the debug menu, but I don't completely understand what it means. Could somebody explain it to me? Thank you in advance.

like image 418
abw333 Avatar asked Aug 02 '11 19:08

abw333


People also ask

What does attaching to a process mean?

i>Attaching</i><i> to the process</i> means telling the CPU to send the instructions in the executable code to a debugger before they're executed by the CPU. In other words, you place the debugger between the executable code and the CPU.

How do you attach a process in VS code?

Attach to a running process Ensure the application sources are stored on your local machine. Open the folder that contains the source files in Visual Studio Code. Click Run > Start Debugging. Select the configuration you want to use, if prompted.

How do I add a process in Visual Studio 2010?

Visual Studio 2010 Express Edition supports Attach to process but it is available only in Expert Settings. Go to Tools->Settings->Expert Settings. After this change, you should see Attach to Process button in Debug menu.

How do you Debug DLL attach to process?

Debug from the DLL project Set breakpoints in the DLL project. Right-click the DLL project and choose Set as Startup Project. Make sure the Solutions Configuration field is set to Debug. Press F5, click the green Start arrow, or select Debug > Start Debugging.


2 Answers

When you Attach to a Process, you're causing the debugger to attach to the process and allow you to set breakpoints within code that you have not started from a debugger. This is very useful in the situation of trying to debug things that have an automatic spawning process (such as .NET code that runs under IIS).

like image 87
Paul Sonier Avatar answered Oct 24 '22 13:10

Paul Sonier


enter image description hereInstead of pressing F5 to start an instance of your app (or pressing the green "go" button), you can attach the debugger to an already running program. While you /can/ attach to an instance of Notepad, since Notepad is not a .net application and you don't have the .pdb debugging symbols for notepad, it won't do much good.

To attach to an already running instance of your program (or an internet explorer instance that is running your code)...

  • compile non-optimized
  • compile "Full" debugging symbols (the default for the DEBUG configuration)
  • make sure the .pdb file is in the same directory as the .dll or .exe (or you can find them manually)
  • make sure the code is in the same path as when it was compiled (or you have to find it manually)
like image 25
agent-j Avatar answered Oct 24 '22 14:10

agent-j