Posts

Showing posts with the label SPWeb

SharePoint 2010 / MSOCAF - Call to Microsoft.SharePoint.SPItemEventProperties.OpenWeb() on Sharepoint 2010. Use Microsoft.SharePoint.SPItemEventProperties.get_Web Property instead.

If you are using the following code: SPWeb web = properties.OpenWeb(); and are getting the following error: Call to Microsoft.SharePoint.SPItemEventProperties.OpenWeb() on Sharepoint 2010.  Use Microsoft.SharePoint.SPItemEventProperties.get_Web Property instead. You will need to update the code to the following, and it should remedy the error: SPWeb web = properties.Web;

SharePoint 2010 / MSOCAF - Disposable type not disposed Microsoft.SharePoint.SPWeb

If you ever get the following warning through the MSOCAF Wizard, Disposable type not disposed Microsoft.SharePoint.SPWeb modify the the following contents: using (SPSite _SPSite = properties.Feature.Parent as SPSite) { using (SPWeb _SPWeb = _SPSite.RootWeb) { ... } } to the following: using (SPSite _SPSite = properties.Feature.Parent as SPSite) { SPWeb _SPWeb = _SPSite.RootWeb; ... } as no explicit rootweb dispose is required. Alternatively, you could also do, SPWeb _SPWeb = SPContext.Current.Site.RootWeb;