在我的SharePoint的代碼,我有以下行:SPDispose忽略屬性沒有忽視
SPWeb web = site.RootWeb; //site is an SPSite object
當我重建我的項目並運行在組件上的SPDispose工具,我得到以下錯誤:
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
Notes: Disposable type not disposed: Microsoft.SharePoint.SPWeb
***This may be a false positive depending on how the type was created or if it is disposed outside the current scope More Information: http://blogs.msdn.com/rogerla/archive/2008/02/12/sharepoint-2007-and-wss-3-0-dispose-patterns-by-example.aspx#SPDisposeCheckID_140
我想要做的是有SPDispose工具會忽略這錯誤,所以我拉着SPDisposeCheckIgnore類和支持枚舉到我的項目,我已經適當地裝飾了我的方法:
[SPDisposeCheckIgnore(SPDisposeCheckID.SPDisposeCheckID_140, "RootWeb does not need disposed.")]
public static void RemoveWebPartFiles(SPFeatureReceiverProperties properties, string assemblyName)
{
...
}
做了這一切之後,我仍然收到錯誤。任何人都知道如何去擺脫這個錯誤?
我試過這個以及...仍然沒有骰子。我將在本週末推出一些示例代碼,看看我是否無法完成這項工作。感謝您查看這個。 – 2012-07-13 18:26:51