Condividi tramite


How to: Register a VSPackage

The managed package framework (MPF) provides attributes to control the registration of managed VSPackages. All registration information is contained in a .pkgdef file. For more information on file-based registration, see CreatePkgDef Utility.

The Visual Studio Package Template creates a VSPackage that is correctly registered. For more information on creating VSPackages, see Walkthrough: Creating a Menu Command By Using the Visual Studio Package Template.

Example

The following code shows how to use the standard registration attributes to register your VSPackage.

<PackageRegistration(UseManagedResourcesOnly:=True)> _
<Guid("0B81D86C-0A85-4f30-9B26-DD2616447F95")> _
Public NotInheritable Class BasicPackage
    Inherits Global.Microsoft.VisualStudio.Shell.Package
[PackageRegistration(UseManagedResourcesOnly = true)]
[Guid("0B81D86C-0A85-4f30-9B26-DD2616447F95")]
public sealed class BasicPackage : Package

Robust Programming

Any package that contains managed ctc resources must run the RegPkg utility with the /codebase switch for the bitmaps associated with the package, such as menu and toolbar icons, to appear.

RegPkg /codebase MyPackage.dll

The experimental registry root is used for VSPackage development. This root is passed to CreatePkgDef from the <TargetRegistryRoot> tag in the .csproj project file and overrides the default root.

After development, VSPackages can be installed on computers that do not have the Visual Studio SDK installed. The .pkgdef file is used to create and modify the necessary registration keys.

See Also

Other Resources

Registering VSPackages

VSPackages