Remote Debugging Of SharePoint Custom Application In Visual Studio

Introduction

In this article, we will explore how to remote debug a SharePoint custom application in Visual Studio (SharePoint Test sever to Dev Server).

Scenario

An application works completely fine in SharePoint Dev environment but fails to work in the test environment. Then, how do we find out the issue in the test environment and make the application work?

Pre-requisite 

Verify whether GAC manage tool is installed or not. If it’s not, then install GAC Manager.

This problem can be resolved using the remote debugging method. The step-by-step procedure is given to resolve the issue.

Sharepoint Test Environment Remote Debugging Steps

Steps 1

Connect to Test Server ->Find Remote Debugger, right click and run as an Administrator.

Sharepoint Test Environment Remote Debuging

Steps 2

Pop up window for setting the unique TCP/IP Port Number will appear on screen,

Sharepoint Test Environment Remote Debuging

If Remote debugger icon does not appear on the desktop then follow the below steps for remote debugger configuration.

Steps 3

Open Windows Explorer and navigate to the following directory - C:\Program Files\Microsoft Visual Studio 14.0\Common7\IDE\Remote Debugger.

Once you're in the Remote Debugger directory, double-click on the appropriate directory name based on the processor of your web front-end server (i.e. x64 is most likely what you'll choose if you're working with SharePoint 2013).

Double click on the msvsmon file,

Sharepoint Test Environment Remote Debuging

Sharepoint Test Environment Remote Debuging

On pop up of the VS remote debugger window Go ->Tools ->permissions, add the username of the Dev server administrator account ->Click Apply ->Ok.

Sharepoint Test Environment Remote Debuging

Steps 4

Run with Administrator open GAC Manager Tool- -> Click following Sharepoint Test Environment Remote Debuging Icon Add your custom solution DLL into GAC Manager -> reset IIS by opening a command prompt by typing "iisreset,

Sharepoint Test Environment Remote Debuging

SharePoint Dev Environment Steps

  1. These final steps of the process will now allow you to connect your instance of Visual Studio with the remote debugging monitor so that you will, at last, be able to step through the C# code of your SharePoint components.

  2. On your workstation, open Visual Studio.

  3. Open your SharePoint site's code solution file.

  4. Once your solution is loaded, open the appropriate .cs file you wish to debug and place your breakpoint(s).

  5. Click Debug -> Attach to Process.

    Sharepoint Test Environment Remote Debuging

    Sharepoint Test Environment Remote Debuging

  6. For Qualifier, update the textbox with the remote debugging server name that you captured in Test Environment Step 3 of the Activate the Visual Studio Remote Debugging Monitor section.

  7. Select the w3wp.exe process that matches the ID that you recorded in Step 5 of Dev Environment to Obtain the Worker Process ID section.

  8. Click the Attach button.

  9. Refresh Test Environment SharePoint application then the debugger will be activated in SharePoint Dev Environment.