Thursday, February 3, 2011

SPDispose Check utility - Integrate with Visual Studio 2010

SPDisposeCheck utility checks whether you have disposed the unmanaged SPSite and SPWeb objects correctly or not. Its a tool that every SharePoint developer needs to have integrated in their Visual Studio boxes.

I have prepared a list of Best Practices for Disposing SharePoint objects:

Guidelines to integrate SPDisposeCheck with Visual Studio Solution:

1. Download the SPDisposeCheck.exe utility from:

2. Open your Visual Studio environment and follow the steps as specified:
a. Go to Tools -> External Tools -> Add
b. Enter Title as SPDisposeCheck
c. Command : C:\Program Files (x86)\Microsoft\SharePoint Dispose Check\SPDisposeCheck.exe
d. Arguments : $(TargetName)$(TargetExt)
e. Initial Directory : $(TargetDir)
f. Check mark the Output window checkbox and
g. Click on the Ok button

See snapshot below:

3. Open your Visual Studio solution project and Build it.

4. Select Tools -> SPDisposeCheck:

5. Open the Output window and you should be able to see a set of messages like this:

6. It also shows up the errors in the Visual Studio Error Messages section as follows:

7. You can even configure additional SPDispose Check settings within Visual Studio 2010 by selecting "SharePointDispose Check" link under Tools, see snapshot below:

Let me know if it helps.


  1. Hi,

    thanks for your post. I have two problems. When I add the SPDisposeCheck as an External tool. It works fine except errors are not shown in the Visual Studio Error Message Section (As shown in 6.).

    Second problem is, that when I click on SharePoint Dispose Check in the Tool Menu (See 7.) The Setting form is empty and if I fill the settings out and try to save it, it is not saved.

    do you have any Idea?



  2. Hi,

    I have exactly the same problem. Settings are not saved.
    Where does it store those settings ? Access rights problem ?

    please help.



  3. Hi,

    I also have the same problem, settings are not saved, no error messages occur.
    VS is started as Administrator, so access rights should not be the cause.

    Any ideas / workarounds?

    Greetings, Thomas

  4. thanks for your posting of installation steps.