This post is migrated from previous hosting provider. There are still some issues with old posts. Please make a comment on this post with any issues.

How to get Remote Debugging work properly

Tags: SharePoint, Visual Studio, Windows Vista, Virtual Server

Remote Debugging is a great feature to use, especially when you work with virtual machines. It allows you to develop and debug locally but have the code running on another machine, virtual or physical. Microsoft SharePoint can't be installed on a Windows Vista or XP workstation, but needs to be installed on Windows Server 2003 or 2008, so the general recommendations has been for developers to have either Windows Server as their main OS or have a virtual machine with Windows Server. None of these work that well; either you have problems debugging your components and you have to rely on traces or message boxes or you have to have a virtual machine with a full development environment, which will not resemble a production machine.

So, Remote Debugging, is my primary way when working with SharePoint development. It allows you to have a smaller virtual machine, and it will allow you to develop in your main OS. But, Remote Debugging has been quite problematic to set up and configure, so here is a guide that you can follow to get it work in a few minutes.

This guide uses Microsoft Visual Studio 2008 and Windows Vista with UAC on the client and a Windows Server 2003 with WSS 3.0 running in a Virtual PC on the client.

Prepare your remote host

First of all you need to prepare your remote host for accepting incoming debugging requests, this is done by running the Visual Studio Remote Debugging Monitor on the remote machine, which is found under C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\Remote Debugger\. Copy that folder to your remote host and place a shortcut to the msvsmon.exe on the desktop, so you have fast access to it whenever you need to debug.

The Remote Debugging Monitor is the one accepting your debug calls and the talking back to Visual Studio on your client, so to get these things to work you have to start the client as the user running Visual Studio (or have administrative permissions on the client). You can either log in to the remote host using that user or, as I prefer, right-click on the msvsmon.exe and choose Run As... Make sure that the user you are using to run the monitor with is member of the local Administrators group.

Remote Debugging Montor

Now the Remote Debugging Monitor has started to waiting for new debugging connections. The debugging server was named with the username that is running the application and the server name, separated with an @-character. You can rename it using Tools->Options.

Prepare your client

imageNow it's time to prepare your client. First of all you have to run the Visual Studio 2008 Remote Debugger Configuration Wizard, which will open up the correct ports in your firewall. You will find the wizard under the Visual Studio Tools in your start menu. The wizard also allows you to run the Remote Debugger as a service on the machine which the wizard is run on, skip this step for this guide. When the wizard asks you for how you would like to configure your firewall, choose the Allow only computers on the local network... option and the finish the wizard.

Start Debugging

Now it's time to start Visual Studio 2008 and load up your solution and hook up the debugger to the remote machine. Prior to this you need to deploy the application to be debugged on the remote machine, including the .pdb files.

In Visual Studio choose Debug->Attach to process. In the Qualifier you have to enter the name that was given to the Remote Debugger Monitor and hit Enter, then all you need to do is attach to the process you would like to debug and set some break points!

image

That wasn't to hard?

Problems

Here are some problems that I have stumbled upon when trying to get these things to work.

Unable to connect to the Microsoft Visual Studio Remote Debugging Monitor named 'XXX. The Visual Studio Remote Debugger on the target computer cannot connect back to this computer. Authentication failed. Please see Help for assistance.

This one is due to the fact that the user running the debugging monitor are not allowed to access the client machine, make sure that the user running the monitor is either the same user running Visual Studio or the member of the Administrators group on your client.

You only see a few processes in the Attach to Process dialog.

First of all make sure you have checked the Show processes from all users check box, then make sure that the user running the monitor has access to the process on the machine, that is you have to make the user member of the local Administrators group. After adding the account to the Administrators group you have to restart the monitor.

Unable to connect to the Microsoft Visual Studio Remote Debugging Monitor named 'ibvsretail'. Logon Failure: The target account name is incorrect.

This one is pretty uncommon, but still I have had it. Somehow the server account in Active Directory had gone wrong so I hade to remove the machine from the domain and add it back.

44 Comments

  • Mcfly said

    Hi, Great guide! I'm wondering however if you can get remote debugging working with vista, vs2008 and a w2k3 server (in virtual server) running sharepoint... The problem is that the two machines are in separate domains...

  • Wictor said

    Hello, try creating a local account on both and run VS and msvsmon as that account. Make sure that both accounts have the same user name and password.

  • Ron said

    No need to run VS under the local account. The account simply needs to exist on the machine where you run VS and have the same password. This allows msvsmon to connect back to your machine.

  • Mattias said

    Hi! Thanks for a nice guide! I'm afraid I can't make this work though. When trying to connect to the server, the server monitor says I connected, but after a short while I get an error msg on my dev client saying: "Unable to connect to the Microsoft Visual Studio Remote Debugging Monitor named 'DOMAIN\user@servername'. This operation returned because the timeout period expired." What might have gone wrong?

  • Mattias said

    Hi! Thanks for a nice guide! I'm afraid I can't make this work though. When trying to connect to the server, the server monitor says I connected, but after a short while I get an error msg on my dev client saying: "Unable to connect to the Microsoft Visual Studio Remote Debugging Monitor named 'DOMAIN\user@servername'. This operation returned because the timeout period expired." What might have gone wrong?

  • Wictor said

    Hi, make sure that "Show all processes from user" and "Show all processes in sessions" are checked and that you have administrative permissions on the remote server.

  • dave said

    Perhaps you shoud just mention that the pdb file has to be placed in the same folder as the dll. If you work with the virtualn directory ( in the .bin directory) and if you work with GAc deplyment the pdb file should be placed in the same folder as the assembly: c:\Assembly\Gac_msil\"yourAssemblyname"\"Version of your Assembly 1.0.0__"the Assemblykey""

  • Trackback said

    Testing releases on the core tech test machine The core tech test box (aka CoreTechWiiDev) is on the desk under the company logo....

  • Trackback said

    Testing releases on the core tech test machine The core tech test box (aka CoreTechWiiDev) is on the desk under the company logo....

  • Trackback said

    Testing releases on the core tech test machine The core tech test box (aka CoreTechWiiDev) is on the desk under the company logo....

  • Wictor said

    1) Make sure that you are admin, 2) make sure that the website is running 3) w3wp.exe might be called aspnet_wp.exe (older versions of IIS/.net)

  • soofy said

    Hi, i can debug class library but asp.net debug symbols are not loaded and i get warning sign on the visual studio break point.

  • rlevv said

    I followed the above steps and when trying to attach to the w3wp.exe process I am getting this error. "Unable to attach to the process. Attaching to a process in a different terminal server session is not supported on this computer. Try remote debugging to the machine and running the Microsoft Visual Studio Remote Debugging Monitor in the process's session." Any ideas?

  • rlevv said

    I followed the above steps and when trying to attach to the w3wp.exe process I am getting this error. "Unable to attach to the process. Attaching to a process in a different terminal server session is not supported on this computer. Try remote debugging to the machine and running the Microsoft Visual Studio Remote Debugging Monitor in the process's session." Any ideas?

  • rlev said

    I finally figured out this problem. I was trying to remote debug where the server hosting the site was an x64 and I was running the x86 remote debugger monitor. I downloaded the x64 version from http://www.microsoft.com/downloads/details.aspx?FamilyID=440ec902-3260-4cdc-b11a-6a9070a2aaab&displaylang=en (installed to C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\Remote Debugger\x64) and ran the msvsmon.exe, and wala! I was able to attach to the process and debug. :)

  • Ravindra Patil said

    I am getting error.I am using XP on client and Windows Server 2008 on Remote machine.Getting an error MSVSMON service is not running.Please help me.

  • Jeff said

    Hi Wictor, Excellent post. Very precise and clear. Just like you describe, I would like to develop locally on my Windows XP where Visual Studio 2008 is installed and run/debug remotely on my Windows 2003 Server VM. What you don't mention here is the best practice for actually referencing the server side DLLs (such as Microsoft.SharePoint.dll) on the client side where VS 2008 is running. This is obviously necessary for compiling and IntelliSence. Should I copy the actual DLLs from the VM into a local folder (GAC, Project/bin, etc)? Should I mount the ISAPI folder shared from the VM on my client and browse for the reference in VS 2008? It seems the latter might be preferable since it does not involve a file copy, but would my solution/feature DLL fail to link on the server side due to nonexistent path there? If you have a post on this, a link should suffice. Best regards.

  • lp larsson said

    One cause to the error "cannot connect back to ..." is if the remote machine can't resolve the NetBIOS name of the machine where Visual Studio is running.
    Try nslookup <NetBIOS name of your local PC>
    Try dir \\<NetBIOS name of your local PC>\c$
    If it can't resolve either add the DNS suffix of the local PC to the DNS suffix search order, or add a line in the c:\Windows\system32\drivers\etc\hosts file.

  • Sikander said

    Getting the error

    "Unable to connect to the Microsoft Visual Studio Remote Debugger Monitor name XXXX. The visual studio remote debugger on the target computer cannot connect back to this computer. A firewell may be preventing communication via DCOM to the local computer. Please see help for assistance"

    I many times turned off my firewall, but every time when I enter IP address of VM and try to connect to remote debugger. It is connected to remote debugger, but then i got this error msg. When i see firewall settings, it is automatically turned ON. Please help.

  • Srikanth said

    Hi ,

    I have .NetFramework 4.0 on my dev machine (Windows Seerver 2008 R2) on which I installed the VS2010 remote debugger and I run a virtual machine under Windows 7 Enterprise installed Visual Studio 2010.and I ran the VS remote debugging monitor on remote machine.

    On Visual Studio 2010 on the host machine, selected Tools -> Attach to Process. Ensured that the Transport method is set to Default. In the Qualifier text box, I entered the server name which was displayed by the Remote Debugger on the remote machine (username@COMPUTERNAME). I then hit enter and I get the following message:

    Unable to connect to Microsoft Visual Studio Debugging Monitor named 'username@COMPUTERNAME'. Access is denied.

    Any help greatly appriciated...

    Regards

    Srikanth Reddy

Add a Comment

AWS Tracker

About Wictor...

Wictor Wilén is a Director and SharePoint Architect working at Connecta AB. Wictor has achieved the Microsoft Certified Architect (MCA) - SharePoint 2010, Microsoft Certified Solutions Master (MCSM) - SharePoint  and Microsoft Certified Master (MCM) - SharePoint 2010 certifications. He has also been awarded Microsoft Most Valuable Professional (MVP) for four consecutive years.

And a word from our sponsors...

SharePoint 2010 Web Parts in Action