How to debug Sharepoint solution / function through Visual Studio?

I recently tried installing webpart through the wspbuilder utility on a Sharepoint site. I created, built and deployed a project in 12 hives. After that, we installed the solution through the Cental Administration site and activated it in the site collection.

I'm just wondering how can I debug a complex function / solution? Since both processes (build-deploy and activate) are completely independent, how can I attach a process to a workflow?

+4
source share
5 answers

The WSPBuilder context menu has the option "Attach to IIS Workflow". While the application is loading (usually this means that you tried to connect to the page on the SharePoint site before trying to connect), and the code deployed in SharePoint matches the code that you have in Visual Studio, you must set breakpoints and run the code.

+3
source

First you need to open a browser and go to the corresponding SharePoint website. Then in Visual Studio, go to Debug -> Attach to Process and find the w3wp.exe process associated with the Sharepoint website that you want to debug. Click on it (the process), and then click the "Attach" button. Now you can debug any activity related to your SharePoint feature.

+2
source

Sometimes itโ€™s a little pain to figure out which w3wp process to join. Try adding the following to your code:

System.Diagnostics.Debugger.Break();

+2
source
 System.Diagnostics.Debugger.Break() 

As suggested by Muhimbi, in some cases it is very useful. Suppose you want to debug your own code (for example, the feature_deactivating event) when it can be called using stsadm, and not with a browser. (for example, you have to use stsadm to deactivate a function when the function is hidden in the user interface). When using stsadm you cannot attach to cmd.exe because it is a separate process. If you type the command and press "Enter" and then find your stsadm.exe process id to join it, it's too late. In such situations, the team above is the simplest and best solution.

+1
source

I tried the steps mentioned here

go to Debug -> Attach to Process and find the w3wp.exe process associated with the Sharepoint website you want to debug

But I get: "Breakpoints will not be deleted, no characters will be loaded into this document." Should I register a custom deployed solution DLL with GACUTIL? Should I copy PDB files to any specific location? What am I missing here?

+1
source

Source: https://habr.com/ru/post/1306057/


All Articles