Share via

ProvideMenuResourceAttribute Class


Provides registration information about menu resources used in a VSPackage. This class cannot be inherited.

public ref class ProvideMenuResourceAttribute sealed : Microsoft::VisualStudio::Shell::RegistrationAttribute
public ref class ProvideMenuResourceAttribute sealed : Microsoft::VisualStudio::Shell::RegistrationAttribute
[System.AttributeUsage(System.AttributeTargets.Class, AllowMultiple=true, Inherited=true)]
public sealed class ProvideMenuResourceAttribute : Microsoft.VisualStudio.Shell.RegistrationAttribute
[<System.AttributeUsage(System.AttributeTargets.Class, AllowMultiple=true, Inherited=true)>]
type ProvideMenuResourceAttribute = class
    inherit RegistrationAttribute
Public NotInheritable Class ProvideMenuResourceAttribute
Inherits RegistrationAttribute


When to Call

Apply the ProvideMenuResourceAttribute to a Microsoft.VisualStudio.Package-derived class or class that implements IVsPackage if the class contains one or more menu resources. Register the resources with regpkg.exe or a similar registration tool. For more information, see Registering VSPackages.

Basic Usage

The ProvideMenuResourceAttribute class defines the resource ID and version number of a menu resource, allowing a registration tool such as regpkg.exe to register the menu resource with Visual Studio. When Visual Studio encounters a VSPackage with a registered menu resource, it retrieves the resource information from the VSPackage or the package's managed or satellite DLL and merges the menu into the Visual Studio menu system. To use ProvideMenuResourceAttribute, place it on a Package-derived class or class that implements IVsPackage.

For the menu resource to merge correctly, the resource DLL must follow the satellite DLL conventions. It must be named <assemblyfile>UI.dll, and placed into an appropriate, localized subdirectory. For additional information on menus and menu resources, see How VSPackages Add User Interface Elements and Commands, Menus, and Toolbars.

This attribute class is only used to provide data for external registration tools. It does not have any effect on the run-time behavior of the VSPackage.


C# automatically appends the word "Attribute" to the name of any attribute class. In C# code, refer to this attribute as ProvideMenuResource.

Registry Entries

  • The following registry entries are created by ProvideMenuResourceAttribute:

  • <VSROOT>\Menus\

  • <VSROOT>\Menus\{PackageGuid}=", ResourceID, Version"


You can find implementations of the ProvideMenuResourceAttribute class in the managed samples. The standard location for this and all other attributes used for automatic registration is adjacent to the implementation of the Package class in VsPkg.cs, VsPkg.vb, or VsPkg.cpp, depending on the language used in the sample.


ProvideMenuResourceAttribute(Int16, Int32)

This constructor creates a new ProvideMenuResourceAttribute object with the given resource ID and version number.

ProvideMenuResourceAttribute(String, Int32)

Initializes a new instance of ProvideMenuResourceAttribute with the specified resource ID and version.



The path to a CSV file which maps the icon identifiers defined in the menu resource to image monikers. The path is either a relative path implicitly rooted at $PackageFolder$, or an absolute path explicitly rooted at a directory defined by an environment variable (e.g. "%UserProfile%\dir1\dir2\MyMappingFile.csv").

The format of the CSV file is:

Icon guid, Icon id, Moniker guid, Moniker id

The ResourceID property returns the value of the resource ID set in the constructor.


Override the TypeID property in order to let the RegistrationAttribute derived classes to work with System.ComponentModel.TypeDescriptor.GetAttributes(...). An attribute derived from this one will have to override this property only if it needs a better control on the instances that can be applied to a class.

(Inherited from RegistrationAttribute)

Returns the version number of the menu resource.



Gets the registry path (relative to the registry root of the application) of the VSPackage.

(Inherited from RegistrationAttribute)

Provides registration information about a VSPackage when called by an external registration tool such as regpkg.exe. For more information, see Registering VSPackages.


Called to unregister this attribute with the given context.

Applies to