"The day you stop learning SharePoint is the day you stop using it."

Remote Debugging a SharePoint 2013 Farm Solution in Visual Studio 2013

You can remotely debug a SharePoint farm solution in your local Visual Studio without having SharePoint locally installed.

1. You have a ready on premise SharePoint Server
2. You have Visual Studio 2013 installed on your local machine. (ex. Windows 7/Windows 10)3. You have created identical debug user accounts on both the local host and server machines and add to Local Administrator group on both machines (not sure if admin group is necessary, but better to add it in Administrators group).

Execution in Windows Registry:
1. Go to your SharePoint Server and export 15.0 hive from regedit.exe (Run As Administrator)-[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\15.0]
2. Enter a meaningful name for this exporting file and save.
3. Copy the exported ‘.reg’ file to your local development machine.

4. On your local development machine, open your regedit.exe (Run as Administrator) and navigate to same path [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\15.0] 
5. Select File > Import > Select your copied .reg file and click Open and you are done.

Steps to perform in Visual Studio 2013:
1. Open Visual Studio 2013 as Administrator.
2. Create a new project (I created a SharePoint 2013 – Visual Web Part)
3. In the below wizard, do not change any values, do not click Validate. Simply click Finish.
4. Copy the required SharePoint DLL to your local development machine and add them to References in your VS solution. (I added only Microsoft.SharePoint.dll. You may need more SharePoint DLL depending on SharePoint classes used in your code.)

Configuration Steps:
1. When you are done coding, build the solution and copy pdb file to the SharePoint server. (You will find this pdb file in bin folder)
2. Right click solution and choose Publish. This will create wsp file.
3. Copy this wsp file to the SharePoint server and deploy the solution:
Use Add-SPSolution and Install-SPSolution.
4. Activate the web part from Site Settings and add it to any SharePoint page.
5. Navigate to one of the below location to find your solution folder:
C:\Windows\assembly\ GAC_MSIL\
6. Copy the pdb file to your solution folder. Now your solution’s DLL and PDB file are in same folder.
7. On the SharePoint server navigate to [C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\Remote Debugger\x64] and run msvsmon.exe as Administrator. You will have below window now running.

8. In the Debugging Monitor window choose > Tools > Permissions and check if the account by which you are running your Visual Studio on your local machine has Debug permission, if not grant it.
9. Open Windows PowerShell on SharePoint Server and run this command:
C:\Windows\System32\inetsrv\appcmd list wp
This command will list all WP process currently running. Note down the WP process ID that you want to attach in Visual Studio. (Example shown below. My Web Part is deployed to 11724, therefore I will choose only this WP ID while attaching to the process in Visual Studio).

Back to Visual Studio 2013:
1. Tools > Attach to Process > Enter “YourDomainName\YourDebugAccount@YourSharePointServerName” in Qualifier field and click Find button.
Example: Octaware\spstp_octaware@tamouh_srv01

2. Choose details returned and press Select.

3. Select “Show processes from all users” and press Refresh button.
4. Among the listed w3wp process, choose the one that you had noted earlier in above step 8.
5. Refresh your SharePoint page and happy remote debugging. (Assuming that your breakpoint is under Page_Load event.)



Riya R said...

Wow, Excellent post. This article is really very interesting and effective.
SharePoint jobs in Hyderabad
SharePoint jobs in Chennai

Riya R said...

informative blog thanks for providing such a great information.
SharePoint jobs in Hyderabad
SharePoint jobs in Chennai

IESGP Internet eBusiness Solutions said...

Awesome! I have been searching for a fix for this. Thanks for sharing!

Dynamics GP Ecommerce

SharePoint-StackExchange Moderator

Author's Profile

My photo
A SharePoint Enthusiast working as a Project Lead for an IT Software & Consulting Company in Mumbai. I believe in giving back to the community through which I also learn and develop and eventually grow as an individual and professional. This blog is a small contribution to the community where I live in and may help someone who is seeking knowledge like me. Apart from being a SharePoint Enthusiasts, I am a husband, a father and a blogger. I love to travel and explore new landscapes and meet people of various culture. I am passionate about learning new technology trends in IT. I love spending time on my fitness and have a deep enthusiasm for urdu poetry and career counseling.

Popular Posts

Powered by Blogger.

Contact Form


Email *

Message *

Total Pageviews