Click here to Skip to main content
15,881,139 members
Articles / Productivity Apps and Services / Sharepoint
Tip/Trick

SharePoint Debugging: Attach all w3wp.exe processes to debugger with single click

Rate me:
Please Sign up or sign in to vote.
5.00/5 (3 votes)
26 Feb 2012CPOL1 min read 22.1K   1   1
How to attach all w3wp.exe processes to debugger with single click.

SharePoint developers know that many times they need to debug their custom SharePoint components like web parts and field types. For this purpose developer needs to attach w3wp.exe process with VS debugger again and again. We can create our own visual studio add-in which will help us to attached debugger to all w3wp processes with just one click.


Steps to create add-in:



  1. Open VS2010.
  2. Select File >> New >> Project.
  3. Select ‘Visual Studio Add-In’, you would find this under ‘Other Project Types’ >> Extensibility.
  4. This will bring wizard. Select appropriate options in wizard. Once wizard finishes use below mentioned code in
    Exec method. This code is responsible to attached w3wp.exe processes with debugger. You can use this code to attached any other process as well.

C#
foreach (EnvDTE.Process process in _applicationObject.Debugger.LocalProcesses)
{
    if (process.Name.ToLower().IndexOf("w3wp") > 0)
    {
        process.Attach();
    }
}

Compile your project and run it. This will open another instance of VS. This will automatically deploy your add-in to your local machine. You can find your add-in in tools menu. Later you can create shortcut of this item in you toolbar as well.


If you want to deploy this add-in to any other machine then you can manually copy add-in file in ‘My Documents\Visual Studio 2010\Addins\’. Once you copy this file open it in any editor and change path of assembly.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer
Australia Australia
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
SuggestionDebug with Windows Console App instead. Pin
Jonathan Matthew Beck17-Apr-13 7:19
Jonathan Matthew Beck17-Apr-13 7:19 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.