Remote Debugging in Visual Studio – Part 2

In my previous post i have explained about How to debug an application using Visual Studio Debugger. There is one more way to debug your remote application using a tool called “msvsmon.exe”. The Remote Debugging Monitor (msvsmon.exe) is a small application that Visual Studio connects to for remote debugging and can be found in the location of %Program Files%\Microsoft Visual Studio 11.0\Common7\IDE\Remote Debugger. Remote Debugging involves two way communication between the Visual Studio Debugger and Visual Studio Remote Debugging Monitor(msvsmon.exe). For remote debugging to work, it is important which user runs Visual Studio and also which user runs msvsmon.exe.  To connect to msvsmon, you must run Visual Studio under the same user account as msvsmon. So  you must have a local user account on each computer, and both accounts must have the same user name and password. I have a simple HelloWorld.exe application on my remote machine. To start remote debugging

  • Copy all pdb files on remote machine and launch your application there.
  • Run msvsmon.exe tool on Remote machine by using visual studio command prompt or launch directly from the location.

msvsmonServerName

  • Copy Server name from msvsmon.exe
  • Open application source code in client machine and launch “Attach To Process” window (CNTRL + ALT + P)
  • Paste server name in “Qualifier” textbox and Refresh will shows all the process from Remote machine
  • Attach the HelloWorld.exe project to debug.

Attach We have option to share pdb files from client side. Follow the below steps to debug your application using shared pdb files. Client machine

  • Create a folder with all pdb files that you want to debug.
  • Share the folder to access everyone.

Server Side

  • Open Command Prompt.
  • Change directory to msvsmon.exe location.
  • Set Symbol Path for msvsmon.exe using “set _NT_SYMBOL_PATH command and launch msvsmon.exe

SymbolShare

Next time onwards visual studio will try to  load symbols from shared path also.

Advertisement

Remote Debugging in Visual Studio – Part 1

Every Visual Studio developer has probably come across the need of Remote Debugging at some point during development. I too faced that situation.Visual Studio supports remote debugging from one computer to another. When you are doing remote debugging, the host computer can be any platform that supports Visual Studio on which you control the debugging process. The remote computer can be a 32-bit or 64-bit Windows or Arm platform on which the debugger is run. It ships along with all versions of Microsoft Visual Studio.

Fore more about setup and configure Remote Debugger please visit  How to: Set Up Remote Debugging

Debugging process is controlled from the host and the listener on the remote computer that executes commands sent from Visual Studio. Here the listener is Remote Debugging monitor (msvsmon.exe).

The next important thing is security. You can either perform debugging in NoAuthentication mode or in Windows Authentication mode. Windows Authentication mode requires the same account to be setup on the host and the remote compute and both usernames and passwords must be the same. NoAuthentication mode which allow all people to access your debugging monitor.

Once finished the configuration part, deploy the application and pdb files on the remote machine and begin with starting msvsmon.exe on the same. We can now either start the application under the debugger or attach the debugger to the already running process.

Let’s start with the first scenario : start the remote debugging by modifying the start project properties page

Debugger1

If you don’t have access to the application solution, then you need to use the application EXE file. From Filemenu choose Open->Project/Solution… and find the EXE file for your application. Select the newly opened project and choose properties. Fill the page with following values:

Debugger2

Pressing F5 will start the remote application, now you can debug application on the remote machine like how you debug application in the local machine.

My next blog is about :  How to Attach and Debug application in Cross Domain