Package Class

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

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

[PackageRegistrationAttribute]
[ComVisibleAttribute(true)]
public abstract class Package : IVsPackage, 
	IServiceProvider, IOleCommandTarget, IVsPersistSolutionOpts, IServiceContainer, IServiceProvider, 
	IVsUserSettings, IVsUserSettingsMigration, IVsUserSettingsQuery, IVsToolWindowFactory, IVsToolboxItemProvider

The Package type exposes the following members.

  NameDescription
Protected methodPackageInitializes a new instance of Package.
Top

  NameDescription
Public propertyApplicationRegistryRootGets the root registry key of the current Visual Studio registry hive.
Public propertyUserDataPathGets the path to user data storage for Visual Studio.
Public propertyUserLocalDataPathGets the path to local user data storage for Visual Studio.
Public propertyUserRegistryRootGets a registry key that can be used to store user data.
Public propertyZombiedGets a value indicating whether the package in the process of shutdown.
Top

  NameDescription
Protected methodAddOptionKeyAdds a user option key name into the list of option keys.
Public methodCreateInstanceCreates the specified COM object using the Visual Studio's local registry CLSID object.
Public methodCreateToolEnables derived classes to provide an implementation if necessary.
Protected methodCreateToolWindowCreates a tool window of the specified type with the specified ID.
Protected methodDisposeReleases the resources used by the Package object.
Public methodEqualsDetermines whether the specified object is equal to the current object. (Inherited from Object.)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public methodFindToolWindowGets the tool window corresponding to the specified type and ID.
Public methodFindWindowPaneGets the window pane corresponding to the specified type and ID, and if no window pane of that type exists creates one if told to do so.
Protected methodGetAutomationObjectGets the automation object for the VSPackage.
Protected methodGetDialogPageGets the requested dialog page.
Public methodStatic memberGetGlobalServiceGets a service proffered globally by Visual Studio or one of its packages. This is the same as calling GetService() on an instance of a package that proffers no services itself.
Public methodGetHashCodeServes as the default hash function. (Inherited from Object.)
Public methodGetOutputPaneGets the requested output window.
Public methodGetProviderLocaleReturns the locale associated with this service provider.
Protected methodGetServiceGets type-based services from the VSPackage service container.
Protected methodGetToolboxItemDataGets the content of the data format for the specified toolbox item ID and data format.
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Protected methodInitializeCalled when the VSPackage is loaded by Visual Studio.
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Protected methodOnLoadOptionsInvoked by the package class when there are options to be read out of the solution file.
Protected methodOnSaveOptionsInvoked by the Package class when there are options to be saved to the solution file.
Protected methodParseToolboxResource(TextReader, Guid)Parses an embedded text resource of appropriate format for information about which items should be added to the Toolbox.
Protected methodParseToolboxResource(TextReader, ResourceManager)Parses an embedded text resource of appropriate format for information about which items should be added to the Toolbox.
Protected methodQueryCloseCalled to ask the package if the shell can be closed.
Protected methodRegisterEditorFactoryRegisters an editor factory with Visual Studio.
Protected methodRegisterProjectFactoryRegisters a project factory with Visual Studio.
Public methodShowOptionPageDisplays a specified tools options page.
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)
Top

  NameDescription
Protected eventToolboxInitializedEvent generated whenever Visual Studio initializes its Toolbox.
Protected eventToolboxUpgradedEvent generated whenever Visual Studio upgrades its Toolbox.
Top

  NameDescription
Explicit interface implemetationPrivate methodIServiceContainer.AddService(Type, ServiceCreatorCallback)Infrastructure. Adds the given service to the VSPackage's service container.
Explicit interface implemetationPrivate methodIServiceContainer.AddService(Type, Object)Infrastructure. Adds the given service to the VSPackage's service container.
Explicit interface implemetationPrivate methodIServiceContainer.AddService(Type, ServiceCreatorCallback, Boolean)Adds the given service to the service container by means of the specified ServiceCreatorCallback.
Explicit interface implemetationPrivate methodIServiceContainer.AddService(Type, Object, Boolean)Infrastructure. Adds the given service to the VSPackage's service container.
Explicit interface implemetationPrivate methodIServiceProvider.GetServiceGets the service of the specified type.
Explicit interface implemetationPrivate methodIServiceContainer.RemoveService(Type)Infrastructure. Removes the given service type from the service container.
Explicit interface implemetationPrivate methodIServiceContainer.RemoveService(Type, Boolean)Infrastructure. Removes the given service type from the service container, and optionally promotes the removal of the service to parent service containers.
Explicit interface implemetationPrivate methodIOleCommandTarget.ExecExecutes a specified command or displays help for a command.
Explicit interface implemetationPrivate methodIOleCommandTarget.QueryStatusQueries the object for the status of one or more commands generated by user interface events.
Explicit interface implemetationPrivate methodIServiceProvider.QueryServiceInfrastructure. Internal IServiceProvider implementation.
Explicit interface implemetationPrivate methodIVsPackage.CloseInfrastructure. Closes and disposes the package.
Explicit interface implemetationPrivate methodIVsPackage.GetAutomationObjectInfrastructure. Gets an automation-friendly object for this package.
Explicit interface implemetationPrivate methodIVsPackage.GetPropertyPageInfrastructure. Proffers access to the Tools menu Options and the property pages of the Customize Toolbox dialog boxes.
Explicit interface implemetationPrivate methodIVsPackage.QueryCloseInfrastructure. Called to ask the VSPackage if the Visual Studio shell can be closed.
Explicit interface implemetationPrivate methodIVsPackage.ResetDefaultsInfrastructure. Resets Toolbox defaults.
Explicit interface implemetationPrivate methodIVsPackage.SetSiteInfrastructure. Initializes the VSPackage in the Visual Studio environment.
Explicit interface implemetationPrivate methodIVsPersistSolutionOpts.LoadUserOptionsInfrastructure. Loads user options for a given solution.
Explicit interface implemetationPrivate methodIVsPersistSolutionOpts.ReadUserOptionsInfrastructure. Reads user options for a given solution.
Explicit interface implemetationPrivate methodIVsPersistSolutionOpts.SaveUserOptionsInfrastructure. Saves user options for a given solution.
Explicit interface implemetationPrivate methodIVsPersistSolutionOpts.WriteUserOptionsInfrastructure. Writes user options for a given solution.
Explicit interface implemetationPrivate methodIVsToolboxItemProvider.GetItemContentGets an item.
Explicit interface implemetationPrivate methodIVsToolWindowFactory.CreateToolWindowInfrastructure. Creates a tool window of the specified type with the specified ID.
Explicit interface implemetationPrivate methodIVsUserSettings.ExportSettingsThis method implements the IVsUserSettings Interface used to manage profiles and import/export settings to XML files.
Explicit interface implemetationPrivate methodIVsUserSettings.ImportSettingsRetrieves a VSPackage's configuration using the Visual Studio settings mechanism when a user selects the import option of the Import/Export Settings feature on the IDE’s Tools menu. This method is part of the implementation of the IVsUserSettings interface used to manage profiles and import/export settings to XML files.
Explicit interface implemetationPrivate methodIVsUserSettingsMigration.MigrateSettingsMigrates settings from a previous version.
Explicit interface implemetationPrivate methodIVsUserSettingsQuery.NeedExportDetermines whether settings have changed and should be re-exported.
Top

The Package class provides a managed implementation of several of the most useful VSIP interfaces. You 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. (This service is available only 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.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft