Note that there are some explanatory texts on larger screens.

plurals
  1. POSPDispose Ignore attribute not ignoring
    primarykey
    data
    text
    <p>In my SharePoint code, I have the following line:</p> <p><code>SPWeb web = site.RootWeb; //site is an SPSite object</code></p> <p>When I rebuild my project and run the SPDispose tool on the assembly, I get the following error:</p> <hr> <blockquote> <p>Module: Blah.SharePoint.Features.Core.dll Method: Blah.SharePoint.Features.Core.Helpers.FeatureDeploymentHelper.RemoveWebPartFiles(Microsoft.SharePoint.SPFeatureReceiverProperties,System.String) Statement: web := site.{Microsoft.SharePoint.SPSite}get_RootWeb() Source: C:\xxx\xxx\Main\Source\SharePoint\Features\Core\Helpers\FeatureDeploymentHelper.cs Line: 26</p> <p>Notes: Disposable type not disposed: Microsoft.SharePoint.SPWeb<br> ***This may be a false positive depending on how the type was created or if it is disposed outside the current scope More Information: <a href="http://blogs.msdn.com/rogerla/archive/2008/02/12/sharepoint-2007-and-wss-3-0-dispose-patterns-by-example.aspx#SPDisposeCheckID_140" rel="nofollow">http://blogs.msdn.com/rogerla/archive/2008/02/12/sharepoint-2007-and-wss-3-0-dispose-patterns-by-example.aspx#SPDisposeCheckID_140</a></p> </blockquote> <hr> <p>What I want to do is to have the SPDispose tool ignore this error, so I have pulled the SPDisposeCheckIgnore class and supporting enum into my project, and I've decorated my method appropriately:</p> <pre><code>[SPDisposeCheckIgnore(SPDisposeCheckID.SPDisposeCheckID_140, "RootWeb does not need disposed.")] public static void RemoveWebPartFiles(SPFeatureReceiverProperties properties, string assemblyName) { ... } </code></pre> <p>After doing all of this, I still receive the error. Anyone know how I might go about getting rid of that error?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload