(This question is related to MOSS 2007. Might also apply to Sharepoint 2010)
I have run SPDisposeCheck v1.3.1 to detect memory leaks in a solution. There is one issue found that I can't seem to resolve. This might be a "false positive". The following code report the error.
Dim page As SPFile = Sitew.GetFile("Source_Folder_Name/Source_Page")
Dim oWebPart As System.Web.UI.WebControls.WebParts.WebPart = Nothing
Using webPartCollectionDocReunion As SPLimitedWebPartManager = page.GetLimitedWebPartManager(UI.WebControls.WebParts.PersonalizationScope.Shared)
Try
Dim oReader As New System.IO.StringReader("<webParts><webPart>...</webPart></webParts>")
Dim oXmlReader As New XmlTextReader(oReader)
oWebPart = webPartCollectionDocReunion.ImportWebPart(oXmlReader, "")
webPartCollectionDocReunion.AddWebPart(oWebPart, "Main", 0)
Finally
webPartCollectionDocReunion.Web.Dispose()
End Try
End Using
The error occurs with the line : oWebPart = webPartCollectionDocReunion.ImportWebPart(oXmlReader, ""). If I comment this line no error is reported. If I change the line to: oWebPart = webPartCollectionDocReunion.WebParts(0), no error is reported.
The issue seems to be related to ImportWebPart. Anyone seen this error reported?
Thanks, Christian