Condividi tramite


Package Class

Provides a managed implementation of the VSIP interfaces required to create a fully functional VSPackage.

Namespace:  Microsoft.VisualStudio.Shell
Assembly:  Microsoft.VisualStudio.Shell (in Microsoft.VisualStudio.Shell.dll)

Syntax

<CLSCompliantAttribute(False)> _
<PackageRegistrationAttribute> _
<ComVisibleAttribute(True)> _
Public MustInherit Class Package _
    Implements IVsPackage, IServiceProvider, IOleCommandTarget, IVsPersistSolutionOpts,  _
    IServiceContainer, IServiceProvider, IVsUserSettings, IVsToolWindowFactory

Dim instance As Package
[CLSCompliantAttribute(false)]
[PackageRegistrationAttribute]
[ComVisibleAttribute(true)]
public abstract class Package : IVsPackage, 
    IServiceProvider, IOleCommandTarget, IVsPersistSolutionOpts, IServiceContainer, IServiceProvider, 
    IVsUserSettings, IVsToolWindowFactory
[CLSCompliantAttribute(false)]
[PackageRegistrationAttribute]
[ComVisibleAttribute(true)]
public ref class Package abstract : IVsPackage, 
    IServiceProvider, IOleCommandTarget, IVsPersistSolutionOpts, IServiceContainer, IServiceProvider, 
    IVsUserSettings, IVsToolWindowFactory
public abstract class Package implements IVsPackage, IServiceProvider, IOleCommandTarget, IVsPersistSolutionOpts, IServiceContainer, IServiceProvider, IVsUserSettings, IVsToolWindowFactory

Remarks

The Package class provides a managed implementation of several of the most useful VSIP interfaces. The implementation is compatible with the .NET Framework. A VSIP developer can create the basic functionality of a VSPackage with relatively little code by deriving from the Package class, overriding some of its methods, and attaching registration attribute classes. The Package class does not provide direct registration support, but it can use attribute classes to supply the necessary registration information to external tools such as RegPkg.exe.

The Package class offers the following services by default. (You can replace them by asking the VSPackage for IServiceContainer, removing them, and adding your own services in their place.)

  • Package

    The package offers itself as a service.

  • IServiceContainer

    Provides the ability to add and remove services. Any service added with "promote" set to true is proffered to Visual Studio through IProfferService. This makes the service global to all VSPackages within Visual Studio. (The VSIP Extras version of IServiceContainer does not support global services, so this service is only available if the VSPackage has already been loaded.)

In addition to these services, Package uses the service architecture of Visual Studio to provide access to any service available through the global service provider, including the entire Visual Studio SDK set of services.

Inheritance Hierarchy

System.Object
  Microsoft.VisualStudio.Shell.Package

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also

Concepts

Managed VSPackages

VSPackages and Managed Package Framework (MPF)

How to: Register Managed VSPackages

Reference

Package Members

Microsoft.VisualStudio.Shell Namespace

IVsPackage