SPSite.Close - Méthode
Closes the site collection and releases resources.
Espace de noms : Microsoft.SharePoint
Assembly : Microsoft.SharePoint (dans Microsoft.SharePoint.dll)
Syntaxe
'Déclaration
Public Sub Close
'Utilisation
Dim instance As SPSite
instance.Close()
public void Close()
Remarques
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 that are obtained through the object after it is closed.
If you create an SPSite object, you can use the Close method to close the object. However, if you have a reference to a shared resource, such as when the object is provided by the SPControl.GetContextSite method or Site property (for example, SPContext.Current.Site), do not use the Close method to close the object, but instead allow SharePoint Foundation or your portal application to manage the object. For more information about object disposal, see Disposing Objects.
Exemples
The following code example illustrates how to use the Close method.
Dim siteCollection As New SPSite("http://" + System.Environment.MachineName)
siteCollection.Close()
SPSite oSiteCollection = new SPSite("http://" + System.Environment.MachineName);
oSiteCollection.Close(); // use the Using directive instead
Voir aussi
Référence
Microsoft.SharePoint - Espace de noms