Best techniques:
- Dispose method
- using clause
- try, catch, and finally blocks
The SPSite.RootWeb property and SPWeb.ParentWeb property create new objects and assign them to a local member variable. So don't forget to dispose them to.
[code]
String str; using(SPSite oSPSite = new SPSite("http://server")) { using(SPWeb oRootWeb = oSPSite.RootWeb) { str = oRootWeb.Title; str = oRootWeb.Url; … additional processing on RootWeb … } }
[/code]
SPSiteCollection Class
This section describes the methods, properties, or operators in the SPSiteCollection object that require the returned SPSite object to be closed after access.
SPSiteCollection.Add Method
The SPSiteCollection.Add method creates and returns a new SPSite object. You should dispose of any SPSite object returned from the SPSiteCollection.Addmethod.
Must visit URL's:
No comments:
Post a Comment