Package Class

Definition

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

[Microsoft.VisualStudio.Shell.PackageRegistration]
[System.Runtime.InteropServices.ComVisible(true)]
public abstract class Package : IServiceProvider, Microsoft.VisualStudio.OLE.Interop.IOleCommandTarget, Microsoft.VisualStudio.OLE.Interop.IServiceProvider, Microsoft.VisualStudio.Shell.Interop.IVsPackage, Microsoft.VisualStudio.Shell.Interop.IVsPersistSolutionOpts, Microsoft.VisualStudio.Shell.Interop.IVsToolboxItemProvider, Microsoft.VisualStudio.Shell.Interop.IVsToolWindowFactory, Microsoft.VisualStudio.Shell.Interop.IVsUserSettings, Microsoft.VisualStudio.Shell.Interop.IVsUserSettingsMigration, Microsoft.VisualStudio.Shell.Interop.IVsUserSettingsQuery, System.ComponentModel.Design.IServiceContainer
Inheritance
Package
Derived
Attributes
Implements

Remarks

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.

Constructors

Package()

Initializes a new instance of Package.

Properties

ApplicationRegistryRoot

Gets the root registry key of the current Visual Studio registry hive.

UserDataPath

Gets the path to user data storage for Visual Studio.

UserLocalDataPath

Gets the path to local user data storage for Visual Studio.

UserRegistryRoot

Gets a registry key that can be used to store user data.

Zombied

Gets a value indicating whether the package in the process of shutdown.

Methods

AddOptionKey(String)

Adds a user option key name into the list of option keys.

CreateInstance(Guid, Guid, Type)

Creates the specified COM object using the Visual Studio's local registry CLSID object.

CreateTool(Guid)

Enables derived classes to provide an implementation if necessary.

CreateToolWindow(Guid, Int32)

Creates a tool window of the specified type with the specified ID.

CreateToolWindow(Type, Int32)

Creates a tool window of the specified type with the specified ID.

CreateToolWindow(Type, Int32, UInt32)

Creates a tool window of the specified type with the specified ID.

Dispose(Boolean)

Releases the resources used by the Package object.

FindToolWindow(Type, Int32, Boolean)

Gets the tool window corresponding to the specified type and ID.

FindWindowPane(Type, Int32, Boolean)

Gets 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.

GetAutomationObject(String)

Gets the automation object for the VSPackage.

GetDialogPage(Type)

Gets the requested dialog page.

GetGlobalService(Type)

Gets 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.

GetOutputPane(Guid, String)

Gets the requested output window.

GetProviderLocale()

Returns the locale associated with this service provider.

GetService(Type)

Gets type-based services from the VSPackage service container.

GetToolboxItemData(String, DataFormats+Format)

Gets the content of the data format for the specified toolbox item ID and data format.

Initialize()

Called when the VSPackage is loaded by Visual Studio.

InstantiateToolWindow(Type)
IsExperimentalInstance(IServiceProvider)
IsLocalService(Type)

Determines whether the specified service type can be retrieved without requiring an RPC transition to the UI thread.

OnLoadOptions(String, Stream)

Invoked by the package class when there are options to be read out of the solution file.

OnSaveOptions(String, Stream)

Invoked by the Package class when there are options to be saved to the solution file.

ParseToolboxResource(TextReader, ResourceManager)

Parses an embedded text resource of appropriate format for information about which items should be added to the Toolbox.

ParseToolboxResource(TextReader, Guid)

Parses an embedded text resource of appropriate format for information about which items should be added to the Toolbox.

QueryClose(Boolean)

Called to ask the package if the shell can be closed.

RegisterEditorFactory(IVsEditorFactory)

Registers an editor factory with Visual Studio.

RegisterProjectFactory(IVsProjectFactory)

Registers a project factory with Visual Studio.

ShowOptionPage(Type)

Displays a specified tools options page.

Events

ToolboxInitialized

Event generated whenever Visual Studio initializes its Toolbox.

ToolboxUpgraded

Event generated whenever Visual Studio upgrades its Toolbox.

Explicit Interface Implementations

IOleCommandTarget.Exec(Guid, UInt32, UInt32, IntPtr, IntPtr)

Executes a specified command or displays help for a command.

IOleCommandTarget.QueryStatus(Guid, UInt32, OLECMD[], IntPtr)

Queries the object for the status of one or more commands generated by user interface events.

IServiceProvider.QueryService(Guid, Guid, IntPtr)

Internal IServiceProvider implementation.

IVsPackage.Close()

Closes and disposes the package.

IVsPackage.GetAutomationObject(String, Object)

Gets an automation-friendly object for this package.

IVsPackage.GetPropertyPage(Guid, VSPROPSHEETPAGE[])

Proffers access to the Tools menu Options and the property pages of the Customize Toolbox dialog boxes.

IVsPackage.QueryClose(Int32)

Called to ask the VSPackage if the Visual Studio shell can be closed.

IVsPackage.ResetDefaults(UInt32)

Resets Toolbox defaults.

IVsPackage.SetSite(IServiceProvider)

Initializes the VSPackage in the Visual Studio environment.

IVsPersistSolutionOpts.LoadUserOptions(IVsSolutionPersistence, UInt32)

Loads user options for a given solution.

IVsPersistSolutionOpts.ReadUserOptions(IStream, String)

Reads user options for a given solution.

IVsPersistSolutionOpts.SaveUserOptions(IVsSolutionPersistence)

Saves user options for a given solution.

IVsPersistSolutionOpts.WriteUserOptions(IStream, String)

Writes user options for a given solution.

IVsToolboxItemProvider.GetItemContent(String, UInt16, IntPtr)

Gets an item.

IVsToolWindowFactory.CreateToolWindow(Guid, UInt32)

Creates a tool window of the specified type with the specified ID.

IVsUserSettings.ExportSettings(String, IVsSettingsWriter)

This method implements the IVsUserSettings Interface used to manage profiles and import/export settings to XML files.

IVsUserSettings.ImportSettings(String, IVsSettingsReader, UInt32, Int32)

Retrieves 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.

IVsUserSettingsMigration.MigrateSettings(IVsSettingsReader, IVsSettingsWriter, String)

Migrates settings from a previous version.

IVsUserSettingsQuery.NeedExport(String, Int32)

Determines whether settings have changed and should be re-exported.

IServiceContainer.AddService(Type, ServiceCreatorCallback, Boolean)

Adds the given service to the service container by means of the specified ServiceCreatorCallback.

IServiceContainer.AddService(Type, Object, Boolean)

Adds the given service to the VSPackage's service container.

IServiceContainer.AddService(Type, ServiceCreatorCallback)

Adds the given service to the VSPackage's service container.

IServiceContainer.AddService(Type, Object)

Adds the given service to the VSPackage's service container.

IServiceContainer.RemoveService(Type, Boolean)

Removes the given service type from the service container, and optionally promotes the removal of the service to parent service containers.

IServiceContainer.RemoveService(Type)

Removes the given service type from the service container.

IServiceProvider.GetService(Type)

Gets the service of the specified type.

Extension Methods

FindAncestor<TElementType>(TElementType, Func<TElementType,TElementType>, Func<TElementType,Boolean>)
FindAncestor<TAncestorType,TElementType>(TElementType, Func<TElementType,TElementType>)

Microsoft internal use only.

FindAncestorOrSelf<TElementType>(TElementType, Func<TElementType,TElementType>, Func<TElementType,Boolean>)
FindAncestorOrSelf<TAncestorType,TElementType>(TElementType, Func<TElementType,TElementType>)
IsAncestorOf<TElementType>(TElementType, TElementType, Func<TElementType,TElementType>)

Microsoft internal use only.

QueryService(IServiceProvider, Guid)

Gets a service exposed by a service provider based on its service type.

QueryService<TService>(IServiceProvider)

Gets a service exposed by a service provider based on its service type.

Applies to