Friday, January 25, 2013

SharePoint & Project Server Remote debugging

In the following text, „Production“ is server environment on which solution is deployed and which you need to debug for errors.  „Test“ is server environment on which your code is located and Visual Studio is installed.
 
User on „Test“ and user on „Production“ must have same username, they do not have to be in the same domain, but, they must have same username / logon name.

1. First check on „Test“ does msvsmon.exe exist in:

C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\Remote Debugger\x64\

or in:

C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\Remote Debugger\x64

If you have msvsmon.exe on „Test“ skip step 2 and go to step 3.

2. If msvsmon.exe does not exist, it can be downloaded from the Microsoft's web pages.

(there is 64 bit and 32 bit version, choose the version that matches your environment) 

3. Copy to msvsmon.exe to „Production“ and Run it as Administrator


4. User on „Production“ must have permissions for debugging


5. Build and deploy your solution/wsp to the server (make sure that the versions of application on „Test“ and applications code on „Production“ are the same


6. Copy the .pdb file from your build directory from „Test“  to the GAC folder on the „Production“ 

NOTE: You can't open GAC folder and copy there directly, follow these steps to copy:
· On „Production“ go to Start à Run

· Write c:\windows\assembly\gac_msil

· Now, you can copy file to the folder where your application  is located in GAC

7. Back to „Test“ and open Visual Studio with code of application


8. Go to Debug --> Attach to process


9. Write the name of „Production“ machine in field Qualifier


10. Attach to appropriate (or all) w3wp.exe


It should sit there for a while loading a whole bunch of symbol files


You should now be able to debug the server


2 comments:

  1. I strongly advise against this.

    1) TEST environment should NOT have ANY development tools (Visual Studio, etc)... TEST is for testing and validating CONFIGURATION CHANGES ONLY. Use of the VS remote debugger is acceptable.

    2) a DEV environment is where ALL development (visual studio, etc) should occur.

    3) Use of remote debugging on a PROD environment means that LIVE REQUESTS MAY GET BLOCKED. When stepping through code in w3wp, NO OTHER IIS REQUESTS WILL BE PROCESSED. To produce such an impact on a PROD environment is irresponsible.

    4) learn to use the SharePoint logging service. (NOT logging to the system event viewer).

    ReplyDelete
    Replies
    1. The point of this post is to explain how to setup remote debugging between two servers. Names "Production" and "Test" are used just as an example. But, if you need to, you can install VS on test machine, and you can (and sometimes you must) debug production machine

      Delete