My current development environment is SharePoint 2010. I am writing some code on feature activated event in my event receiver. Idea is to add some web parts on the page through code.
Here is the example code
using (SPLimitedWebPartManager manager = web.GetLimitedWebPartManager(pageUrl, WCWP.PersonalizationScope.Shared))
{
try
{
manager.AddWebPart(,,,,,);
manager.SaveChanges(...);
}
catch(Exception ex)
{
}
}
There are no issues in the code and the purpose it intends to accomplish. When I run MSOCAF for my solution it complains about code above, that "GetLimitedWebPartManager" returns SPWeb object and it should be disposed explicitly. The solution it suggests is
finally
{
manager.Web.dispose();
}
even after disposing the Web property of my object MSOCAF is still reporting the same error.
Any suggestions will be of great help.