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: http://www.sharepointfix.com/2008/12/best-practices-disposing-sharepoint.html

Guidelines to integrate SPDisposeCheck with Visual Studio Solution:

1. Download the SPDisposeCheck.exe utility from: http://download.microsoft.com/download/B/4/D/B4D279A0-E159-40BF-A5E8-F49ABDBE95C7/SPDisposeCheck.msi

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.

4 comments:

  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?

    thanks,

    Karim

    ReplyDelete
  2. Hi,

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

    please help.

    Thanks.

    Serge

    ReplyDelete
  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

    ReplyDelete
  4. thanks for your posting of installation steps.

    ReplyDelete