This documentation is archived and is not being maintained.

How to: Register a VSPackage (C#)

[This topic is pre-release documentation and is subject to change in future releases. Blank topics are included as placeholders.]

The managed package framework (MPF) provides attributes to control the registration of managed VSPackages. The RegPkg utility uses these attributes to register a VSPackage for development. By default, Regpkg is located at <drive>:\Program Files\Visual Studio 2005 SDK\<build number>\VisualStudioIntegration\Tools\Bin.

To obtain syntax and parameter information, run RegPkg with the /? switch.

NoteNote

The Visual Studio Integration Package Wizard creates a VSPackage that is correctly registered to run in Visual Studio. For more information on creating VSPackages, see How to: Create VSPackages (C#).

Example

The code that follows is from the Reference.Package Sample (C#).


      [MsVsShell.DefaultRegistryRoot
    (@"Software\Microsoft\VisualStudio\8.0Exp")]
[MsVsShell.PackageRegistration(UseManagedResourcesOnly = true)]
[Guid("01069CDD-95CE-4620-AC21-DDFF6C57F012")]
public class BasicPackage : MsVsShell.Package
{

The DefaultRegistryRootAttribute attribute sets the default registration to the experimental root, typically located at: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\8.0Exp.

The PackageRegistrationAttribute registers the VSPackage with Visual Studio under the Packages key of that root, that is, HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\8.0Exp\Packages.

Robust Programming

The DefaultRegistryRootAttribute attribute sets the default registry root. The actual registry root is determined by the /root argument of the RegPkg.exe command-line utility, which is run as part of the build process. If the /root argument is not given, RegPkg uses the default registry root instead.

The experimental registry root is used for VSPackage development. This root is passed to RegPkg from the <TargetRegistryRoot> tag in the .csproj project file and overrides the default root. RegPkg effectively runs as follows:

RegPkg /root 8.0Exp MyPackage.dll

After development, VSPackages can be installed on computers that have no Visual Studio SDK. The RegPkg utility is not redistributable, but RegPkg can be used to generate a registration manifest for a managed VSPackage. This manifest can be incorporated into an MSI installer. For more information, see How to: Generate Registry Information for an Installer (C#).

See Also

Other Resources

Registering VSPackages
VSPackages

Show: