Visual Studio: Remote Debugging Of SharePoint Custom Application
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.
Steps 2
Pop up window for setting the unique TCP/IP Port Number will appear on screen,
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,
On pop up of the VS remote debugger window Go ->Tools ->permissions, add the username of the Dev server administrator account ->Click Apply ->Ok.
Steps 4
Run with Administrator open GAC Manager Tool- -> Click following https://csharpcorner-mindcrackerinc.netdna-ssl.com/article/remote-debugging-of-sharepoint-custom-application-in-visual-studio/Images/Remote%20Debugging%20Of%20SharePoint%20Custom%20Application%20In%20Visual%20Studio6.jpg Icon Add your custom solution DLL into GAC Manager -> reset IIS by opening a command prompt by typing "iisreset,
SharePoint Dev Environment Steps
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.
On your workstation, open Visual Studio.
Open your SharePoint site's code solution file.
Once your solution is loaded, open the appropriate .cs file you wish to debug and place your breakpoint(s).
Click Debug -> Attach to Process.
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.
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.
Click the Attach button.
Refresh Test Environment SharePoint application then the debugger will be activated in SharePoint Dev Environment.