2
votes
3answers
96 views

To Dispose or Not to Dispose - IDisposable Passed as Function Parameter

If an IDisposable SharePoint object is passed into a function, does an explicit Dispose() call need to be made on it? Example: public void TheCallingFunction() { SPSite site = ...
1
vote
1answer
415 views

Dispose issue when working with content types

I am seeing an issue with un-disposed SPRequest objects in the ULS logs when i work with content types in the object model. My code is as follows (in previous methods run as part of this request, the ...
2
votes
3answers
132 views

4 using statements looks messy? Any suggestions on what is a better way to code this?

Imagine the following code: using (SPSite spSite = new SPSite(this.SiteURL)) { using (SPWeb spWeb = spSite.OpenWeb()) { using (SPSite spSite2 = new SPSite(this.SiteURL2)) { ...
26
votes
2answers
7k views

When to use OpenWeb() vs RootWeb

I am a little confused on the pro's and con's of each. When is it good to use OpenWeb() vs RootWeb, especially in the context of a using statement.
5
votes
3answers
2k views

Should I dispose SPWeb or SPList?

I am doing a whole bunch of things with one SPWeb and many SPLists. If I just dispose web in the finally section would that dispose all of SPLists that I instantiated? (btw, I understand the concept ...