IVsPackage.Close Method
Closes the VSPackage, releases cached interface pointers, and unadvises event sinks.
Namespace: Microsoft.VisualStudio.Shell.Interop
Assembly: Microsoft.VisualStudio.Shell.Interop (in Microsoft.VisualStudio.Shell.Interop.dll)
Syntax
'Dichiarazione
Function Close As Integer
'Utilizzo
Dim instance As IVsPackage
Dim returnValue As Integer
returnValue = instance.Close()
int Close()
int Close()
abstract Close : unit -> int
function Close() : int
Return Value
Type: System.Int32
If the method succeeds, it returns S_OK. If it fails, it returns an error code.
Remarks
This method will clean up any external references and break any reference counting cycles. After all VSPackages' Close methods have been called, the environment releases all proffered services.
The following semantics should be adhered to in the implementation of Close Method:
Once a VSPackage is loaded, it will not be unloaded until the environment application ends. If one VSPackage Close method is being called, then every VSPackage Close method is called. This means a given VSPackage handles its own shutdown and cleanup requirements.
The VSPackage will clean up all external references. The Close method is intended to break all reference counting cycles and to encourage all reference counts to eventually reach zero. You should release cached interface pointers, unadvise event sinks, and provide other necessary cleanup duties. VSPackages must be sure to honor all reference counts. A VSPackage cannot delete objects when the Close method is called.
All services of the environment and all loaded VSPackages remain accessible during the Close method implementation. The VSPackage, however, must expect that the services are unavailable and that the only methods that are guaranteed to succeed are unadvise methods. Most services are expected to fail, to advise new event sinks, or to create new resources.
A VSPackage should not call the RevokeService method in its implementation of the Close method. All services are expected to remain available for the duration of calling Close on VSPackages. The environment automatically revokes and releases the services after VSPackages have called Close.
It is meaningless to return an error from Close. All error Return Values are ignored and the environment completes the shutdown process once it has started. The VSPackage has an opportunity to stop the shutdown process in its QueryClose method.
If a package needs to block shutdown of the IDE it should implement IVsPackage2.
.NET Framework Security
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.