Sei sulla pagina 1di 5

We have deployed a web application on a client machine and the client reports a bug.

Then we
try to replicate the problem in our local environment (where the code exists), but could not
succeed. Now there are two ways to debug the client installation either through log files or
through visual studio debug mode. If our logging is not detailed, we will have nightmares in
troubleshooting. The other option is installing visual studio in a server machine (which is not a
great idea).
To solve this remote debug problem, we can use a tiny tool called Remote Debugging Monitor
(MSVSMON.EXE). It lets you run, debug, and test an application that is running on one device
(client machine) from another computer (local development environment) that is running Visual
Studio.
Pre-Requisites:
1. The remote device and the Visual Studio computer must be connected over a network or
connected directly through an Ethernet cable. Debugging over the internet is not
supported.
2. The remote device must be running the remote debugging components.
3. You must be an administrator to install the remote debugger on the remote device. To
communicate with the remote debugger, you must have user access to the remote device.
Installation:
1. Go to Visual Studio Installation Image file. Mount the Image and click on the Remote
tools. Select rtools_setup_x64.exe and Install

2. Go to C:\Program Files\Microsoft Visual Studio 11.0\Common7\IDE\ and run


rdbgwiz.exe

3. Write LocalSystem in the username.

4. Select the type of networks that you want the remote debugger to communicate with. At
least one network type must be selected.
5. Click next button and then finish button. This will install debugger as an application and
not as a service.
6. Now go to C:\Program Files\Microsoft Visual Studio 11.0\Common7\IDE\Remote
Debugger\x64. Run msvsmon.exe as an administrator. This will run the remote
debugging monitor listening for an incoming request. It will also show the Name and
port number through which we can connect to the client machine.

7. To change the Authentication mode or to specify a timeout value for the remote debugger,
choose Options on the Remote Debugging Monitor Tools menu.
(You can choose to run the remote debugger in No Authentication mode, but this mode is
strongly discouraged. There is no network security when you run in this mode. Choose
the No Authentication mode only if you are sure that the network is not at risk of from
malicious or hostile traffic.)
8. By default, Administrators of the remote device can connect to the remote debugger. To
grant or deny other users permission to use the remote debugger, choose Permissions on
the Tools menu.

Instructions:
1. Before connecting to the client machine, first initiate a worker process on the client PC.
To initiate a worker process you need to run the application, the IIS will do the rest.
2. Once started, open the instance of visual studio where the original code was developed
and navigate to Debug -> Attach to Process
3. By default this lists the process running in the local machine.
4. To connect to the remote servers process, enter the machine name in the Qualifier field
(Editable field). This detail can be obtained from the Remote Debugging Monitor (Listed
above). It displays the machine name with the port number once Remote Debugging
Monitor (MSVSMON.EXE) is started.
5. If you are accessing the Remote Debugging Monitor outside the domain, it will prompt
for authentication. Authorization is based on the permission as configured in the Remote
Debugging Monitor (under permission settings as discussed earlier).

6. Once connected, we can attach to the required process to debug the application. In this
instance, to debug the ASP .Net application we have attached to W3WP.exe of the remote
machine (Client installation). Also we can attach services like normally before.
7. Open Visual Studio with your project. Select attach to process. From the transport drop
down select remote. Now go to the client machine and
8. Now the Visual Studio debug will work as expected from the local machine (development
environment). For process requiring higher permissions, you need to run the Remote
Debugging Monitor (MSVSMON.EXE) as admin in remote machine.
Troubleshooting:
Sometimes even if you attach the correct process, the VS Debug mode does not detect the
process. It might be due to one of the below reasons:
Make sure you copy the .PDB file that is generated with your assembly into the same folder on
the remote machine. This will allow the debugger to pick up the debug symbols.
Make sure that you are using the correct version of MSVSMON.exe 64 bit version is for
debugging 64 bit C# application Which cannot be used with x86 application instance.

Potrebbero piacerti anche