Skip to content

Instantly share code, notes, and snippets.

@hschne
Last active August 29, 2015 14:04
Show Gist options
  • Save hschne/f47bf4697a283bbcb25a to your computer and use it in GitHub Desktop.
Save hschne/f47bf4697a283bbcb25a to your computer and use it in GitHub Desktop.
Darkest Magic or Using the Visual Studio Remote Debugger

#Using the Visual Studio Remote Debugger

###Introduction Imagine you were to deploy an application developed in Visual Studio to a remote server, or some virtual machine or something. Funny things happen, and on this one single machine, you application displays some rather weird behaviour. How are you gonna debug that? Well, fret not and enter the dark and magic world of remote debugging.

##Tutorial

###Attach to process

Open your favourite version of visual studio. Head over to the menu entry Debug and Attach to Process. You can select a process running on the machine specified in the field Qualifier to attach your debugger to and hit that attach button. Visual Studio will enter the debug mode. You can now hit breakpoints set in visual studio by steering the selected process, just like you would when hitting that debug button.

"How the Hell does this help me?" you may ask?

Patience young Padawan! Remember that qualifier field? Well, guess what, you may specify any machine, listing any processes on that machine, and attaching the debugger to any of those processes. But first there are some preparations to make.

###Preparing the remote machine Download and install the Microsoft Visual Studio Remote Debugger for your version of visual studio on the remote machine. Next configure the remote debugger with the Remote Debugger Configuration Wizard. This one might be called slightly differently depending on the version of Visual studio you are using. Make sure the checkbox for running the service is checked. Enter a user name and password that has the described privileges. Ideally you'd enter an administrator account. To make sure that the privilege to "Log on as a service" is granted run "secpol.msc". This opens the Local Security Policy. Open the Local Policies Folder and double click on User Rights Assignment. Search for the entry "Log on as a service", double click that badass and add the previously specified user.

Thats it. Ez.

###Attach to remote process Open the Attach Process window in Visual Studio and enter the IP or name of the machine your application is running on. Hit enter and you will be asked to login. Enter the credentials you specified when configuring the remote debugging service. If all went well, you will be shown the processes running on the remote machine. If it didn't have a look at the common errors section below. You may now select a process and attach the debugger to it, just like you would on the local machine.

##Common Errors

You must use the remote debugger corresponding to your visual studio version.

When using Visual Studio 2010, you must be logged in as the same user as configured in the remote debugger configuration.

The service must be running.

Specifiying an ip is not possible in Visual Studio 2010.

##Additional Links

Download Debugger for Visual Studio 2010: http://www.microsoft.com/de-at/download/details.aspx?id=475

Add Logon Service to account http://technet.microsoft.com/en-us/library/cc739424(v=ws.10).aspx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment