SPWeb.Dispose method

釋放該網站的目前執行個體所使用的所有資源。

Namespace:  Microsoft.SharePoint
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)

Syntax

'宣告
Public Sub Dispose
'用途
Dim instance As SPWeb

instance.Dispose()
public void Dispose()

Implements

IDisposable.Dispose()

備註

Call Dispose when you are finished using this class. The Dispose method leaves this class in an unusable state. After calling Dispose , you must release all references to this class so the garbage collector can reclaim the memory that the class was occupying. For more information, see Cleaning Up Unmanaged Resources and Implementing a Dispose Method. For specific guidance on disposing SharePoint classes, see Best Practices with SharePoint Foundation: Disposing Objects.
Note Always call Dispose before you release your last reference to this class. Otherwise, the resources it is using will not be freed until the garbage collector calls this object's Finalize method.

這個方法只會呼叫Close方法。使用此方法或Close方法來釋放資源的SPWeb物件,當您完成使用物件。物件或關閉之後,即會透過物件中取得的物件不重複使用。

如果您建立SPWeb物件,您可以使用這個方法來關閉物件。不過,如果有共用的資源,例如當物件由SPControl.GetContextWeb方法的參考並不使用這個方法來關閉該物件,但改為允許SharePoint Foundation或入口網站應用程式來管理物件。如需有關物件處置的詳細資訊,請參閱Disposing Objects

請參閱

參照

SPWeb class

SPWeb members

Microsoft.SharePoint namespace

其他資源

Disposing Objects