1
我在我的SharePoint程序集上運行了SPDisposeCheck工具,但它在SiteDefinitionAssembly上報告了三個錯誤,該錯誤也包含站點配置處理程序。據我瞭解,這個代碼是由項目模板本身生成的,我們不應該改變它。我得到的錯誤是SPDisposeCheck在SiteProvisioning.RestoreDataViewOutZone方法上報告錯誤
ID: SPDisposeCheckID_160
Module: SynergyOnline.NFER.ProjectSiteDefinition.dll
Method: ProjectSiteDefinition.SiteProvisioning.RestoreDataViewInZone(Microsoft.S
harePoint.SPWeb,System.String)
Statement: local6 := local5.{Microsoft.SharePoint.SPFile}GetLimitedWebPartManage
r(1)
Notes: Dispose/Close was not called on SPLimitedWebPartManager.Web
More Information: http://blogs.msdn.com/rogerla/archive/2008/02/12/sharepoint-20
07-and-wss-3-0-dispose-patterns-by-example.aspx#SPDisposeCheckID_160
----------------------------------------------------------
ID: SPDisposeCheckID_160
Module: SynergyOnline.NFER.ProjectSiteDefinition.dll
Method: ProjectSiteDefinition.SiteProvisioning.RestoreDataViewOutZone(Microsoft.
SharePoint.SPWeb,System.String)
Statement: local12 := local5.{Microsoft.SharePoint.SPFile}GetLimitedWebPartManag
er(1)
Notes: Dispose/Close was not called on SPLimitedWebPartManager.Web
More Information: http://blogs.msdn.com/rogerla/archive/2008/02/12/sharepoint-20
07-and-wss-3-0-dispose-patterns-by-example.aspx#SPDisposeCheckID_160
----------------------------------------------------------
ID: SPDisposeCheckID_160
Module: SynergyOnline.NFER.ProjectSiteDefinition.dll
Method: ProjectSiteDefinition.SiteProvisioning.RestoreDataViewOutZone(Microsoft.
SharePoint.SPWeb,System.String)
Statement: local14 := local11.{Microsoft.SharePoint.SPFile}GetLimitedWebPartMana
ger(1)
Notes: Dispose/Close was not called on SPLimitedWebPartManager.Web
More Information: http://blogs.msdn.com/rogerla/archive/2008/02/12/sharepoint-20
07-and-wss-3-0-dispose-patterns-by-example.aspx#SPDisposeCheckID_160
----------------------------------------------------------
這裏是gerenrated
private void RestoreDataViewInZone(SPWeb web, string filePath)
{
if (!File.Exists(filePath) || web == null)
{
return;
}
XmlDocument doc = new XmlDocument();
try
{
doc.Load(filePath);
}
catch (XmlException)
{
return;
}
XmlNodeList xFixupFiles = doc.DocumentElement.SelectNodes("FixupFiles/FixupFile[@DataViewInZone=\"TRUE\"]");
foreach (XmlNode xFixupFile in xFixupFiles)
{
XmlAttribute xRelativePath = xFixupFile.Attributes["RelativePath"];
if (xRelativePath == null)
{
continue;
}
string relativePath = xRelativePath.Value;
SPFile file = web.GetFile(relativePath);
if (file == null)
{
continue;
}
SPLimitedWebPartManager manager = file.GetLimitedWebPartManager(System.Web.UI.WebControls.WebParts.PersonalizationScope.Shared);
SPLimitedWebPartCollection pageWebParts = manager.WebParts;
if (pageWebParts == null)
{
continue;
}
foreach (System.Web.UI.WebControls.WebParts.WebPart webPart in pageWebParts)
{
DataFormWebPart dataForm = webPart as DataFormWebPart;
if (dataForm == null)
{
continue;
}
this.SubstituteGuidInZone(web, manager, dataForm, filePath);
}
}
}
我不知道SPWeb對象不設置在功能,但我不知道是否應該設置或代碼不。
我需要擔心這個錯誤嗎?
由於