SPDisposeCheck using Static Analysis

I’ve created a static analysis ruleset for SPDisposeCheck!

SPDisposeCheck is a valuable tool developed by a small team within Microsoft Premier Support led by Roger Lamb that inspects an assembly to ensure that SharePoint API objects are properly disposed. Failure to properly dispose SharePoint API objects can cause memory leaks. The SPDisposeCheck tool can be downloaded here:


The source and compiled versions are available on CodePlex:


Here are the steps to get this up and running on your SharePoint projects:

Copy the SPDisposeCheck SPDisposeCheckRules.dll and the SPDisposeCheck.exe to your local static analysis rules folder.

Example: C:\Program Files\Microsoft Visual Studio 9.0\Team Tools\Static Analysis Tools\FxCop\Rules

Open a SharePoint project and select Project Properties. Select the Code Analysis tab. You should see a new ruleset available called SPDisposeCheck Rules.

If you select Enable Code Analysis on Builds and Treat Warnings as Error for the SPDisposeCheck ruleset, developers should see any SPDispose errors on build for any code added to the solution.  

5 Responses to “SPDisposeCheck using Static Analysis”

  1. Emogene Shawber Says:

    Many thanks for the information. I appreciate it. You have a very nice website.

  2. Austin Mccalister Says:

    Hi – just a brief note to say kudos for this entry. Very informative.

  3. SPDisposeCheck and SharePoint 2010 « Stef van Hooijdonk Says:

    […] even more usefull: SPDisposeCheck using Static Analysis in TFS ( 2010 […]

  4. jthake Says:

    I’ve just rebuilt that project for VS2010 and it’s working fine for 2010 projects 😉

  5. SPDisposeCheck Static Code Analysis RuleSet for Visual Studio 2012 | Ayman El-Hattab Says:

    […] wonderful RulSset has been originally created by Stephen Vick, I just tweaked it a little bit to make it work with Visual Studio […]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: