Close Method

The Close method of the SPSite class closes the site collection and releases resources.

Remarks

Calling the Close method has the same effect as calling the Dispose method. Use the Close method to close the SPSite object and release resources when you are finished using the object. Do not reuse the object or objects obtained through the object after it is closed.

Example

The following code example illustrates how to use the Close method.

Remarks

Calling the Close method has the same effect as calling the Dispose method. Use the Close method to close the SPSite object and release resources when you are finished using the object. Do not reuse the object or objects obtained through the object after it is closed.

Warning  Do not use this method to close a shared resource, such as when the site collection object is provided by the GetContextSite method in a Web Part. Instead let Windows SharePoint Services or your portal application manage the object. Using this method on a shared resource causes an access violation error to occur.

Requirements

Platforms: Microsoft Windows Server 2003

Security: Code Access Security