Click here to Skip to main content
Click here to Skip to main content

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

By , 26 Feb 2012
Rate this:
Please Sign up or sign in to vote.

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.
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)

About the Author

Rahil Jan Muhammad
Software Developer Comcity (www.comcity.com.au)
Australia Australia
I have completed my BS in Software Engineering and MS in Data Engineering & AI system.I have a vast experience in software development using .NET, Oracle and SQL Server
Currently I am working with Comcity (www.comcity.com.au). Comcity is an Austrian IT company, providing services since 2000.

Comments and Discussions

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

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

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

| Advertise | Privacy | Mobile
Web02 | 2.8.140415.2 | Last Updated 26 Feb 2012
Article Copyright 2012 by Rahil Jan Muhammad
Everything else Copyright © CodeProject, 1999-2014
Terms of Use
Layout: fixed | fluid