Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Attaching Visual Studio debugger from command line

I'm using vsjitdebugger.exe -p {pid} to attach the visual studio debugger to a running process. It works, but with the annoyance that a popup window prompts me to select a debugger to attach and I can either choose the open instance of visual studio or start a new instance. Is it possible to pass in the .sln file I want it to attach to so that I don't get that prompt? I could choose new instance as the default, but I was hoping I could specify a .sln file so that it would either open that solution or attach to it if it's already open.

Thanks, Greg

Edit: I was hoping for a programmatic way of doing this. My application is being run by a testing framework and I want it to run without having to click on anything. The help dialog for vsjitdebugger.exe doesn't mention that what I want is possible. What I really want is the ability to do: vsjitdebugger.exe -p {pid} -s 'solution.sln' and bypass that popup.

like image 379
Greg McDowell Avatar asked Apr 19 '11 14:04

Greg McDowell


People also ask

How do I debug a command line argument in Visual Studio?

To set command-line arguments in Visual Studio, right click on the project name, then go to Properties. In the Properties Pane, go to "Debugging", and in this pane is a line for "Command-line arguments." Add the values you would like to use on this line. They will be passed to the program via the argv array.

How do I debug code in Visual Studio line by line?

Run to a breakpoint in code You can also select the line and then select F9, select Debug > Toggle Breakpoint, or right-click and select Breakpoint > Insert Breakpoint. The breakpoint appears as a red dot in the left margin next to the line of code. The debugger suspends execution just before the line runs.

What does attaching to debugger 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 I connect to a debugger in Windows service?

In the Options dialog box, choose Debugging, Symbols, select the Microsoft Symbol Servers check box, and then choose the OK button. The Processes dialog box appears. Select the Show processes from all users check box. In the Available Processes section, choose the process for your service, and then choose Attach.


1 Answers

Have a look at this article, although it uses macro's you could convert into C# or vb.net reasonable easy.

http://www.codeproject.com/KB/macros/AttachedProcess.aspx

like image 174
Stephen Gennard Avatar answered Sep 30 '22 17:09

Stephen Gennard