Partager via


ProvideMenuResourceAttribute Class

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

Namespace:  Microsoft.VisualStudio.Shell
Assemblies:   Microsoft.VisualStudio.Shell.10.0 (in Microsoft.VisualStudio.Shell.10.0.dll)
  Microsoft.VisualStudio.Shell.9.0 (in Microsoft.VisualStudio.Shell.9.0.dll)
  Microsoft.VisualStudio.Shell (in Microsoft.VisualStudio.Shell.dll)

Syntax

'Déclaration
<AttributeUsageAttribute(AttributeTargets.Class, AllowMultiple := True, Inherited := True)> _
Public NotInheritable Class ProvideMenuResourceAttribute _
    Inherits RegistrationAttribute
'Utilisation
Dim instance As ProvideMenuResourceAttribute
[AttributeUsageAttribute(AttributeTargets.Class, AllowMultiple = true, Inherited = true)]
public sealed class ProvideMenuResourceAttribute : RegistrationAttribute
[AttributeUsageAttribute(AttributeTargets::Class, AllowMultiple = true, Inherited = true)]
public ref class ProvideMenuResourceAttribute sealed : public RegistrationAttribute
[<SealedAttribute>]
[<AttributeUsageAttribute(AttributeTargets.Class, AllowMultiple = true, Inherited = true)>]
type ProvideMenuResourceAttribute =  
    class
        inherit RegistrationAttribute
    end
public final class ProvideMenuResourceAttribute extends RegistrationAttribute

Remarks

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 to the IDE and 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.

Notes

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"

Samples

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.

Inheritance Hierarchy

System.Object
  System.Attribute
    Microsoft.VisualStudio.Shell.RegistrationAttribute
      Microsoft.VisualStudio.Shell.ProvideMenuResourceAttribute

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also

Reference

ProvideMenuResourceAttribute Members

Microsoft.VisualStudio.Shell Namespace

Other Resources

Menus and Toolbars

Localized Resources in MFC Applications: Satellite DLLs

Registering VSPackages