How:
SPDisposeCheck Download link:http://download.microsoft.com/download/B/4/D/B4D279A0-E159-40BF-A5E8-F49ABDBE95C7/SPDisposeCheck.msi
SPDispose info:http://msdn2.microsoft.com/en-us/library/aa973248.aspx
SPDispose Team:http://blogs.msdn.com/rogerla/archive/2008/02/12/sharepoint-2007-and-wss-3-0-dispose-patterns-by-example.aspx
Before install the tool, go to
"C:\Program Files\Microsoft\SharePoint Dispose Check\", you can check that this folder contains the file "SPDisposeCheck.exe.
To run spdisposecheck tool on "post built events" you must check the next steps:
- First add "SPDisposeCheck.exe" to "environment variables" or put the "SPDisposeCheck.exe" in System32 Folder.
Now your enviroment has ready to use SPDisposeCheck
Now your enviroment has ready to use SPDisposeCheck
The SPDisposeCheck tool only check assemblies or exe files, you must verify your output type.
In your project go to "Built Events" and add the following command line:
___________________________________________________
SPDisposeCheck "$(TargetPath)" -debug > c:\logs\CheckDisposeLog.txt
SPDisposeCheck "$(TargetPath)" -debug > c:\logs\CheckDisposeLog.txt
___________________________________________________
"$(TargetPath)" -> "c:\...\...\...\...\...\project\bin\(debug/release)\projectname.exe"
or
"$(TargetPath)" -> "c:\...\...\...\...\...\project\bin\(debug/release)\projectname.dll"
"$(TargetPath)" -> "c:\...\...\...\...\...\project\bin\(debug/release)\projectname.dll"
"> c:\logs\CheckDisposeLog.txt" -> location of your report
Its more simple for you use post built macros.
Now, built the solution and test it:
My code with the correct dispose:
Check log file