Commands.AddNamedCommand(AddIn, String, String, String, Boolean, Int32, Object[], Int32) Method


Creates a named command that is saved by the environment and made available the next time the environment starts, even if the VSPackage is not loaded on environment startup.

Add-ins are now deprecated. For more information, see FAQ: Converting Add-ins to VSPackage Extensions.

EnvDTE::Command AddNamedCommand(EnvDTE::AddIn const & AddInInstance, std::wstring const & Name, std::wstring const & ButtonText, std::wstring const & Tooltip, bool MSOButton, int Bitmap = 0, std::Array <winrt::Windows::Foundation::IInspectable const &> const & & ContextUIGUIDs, int vsCommandDisabledFlagsValue = 16);
public EnvDTE.Command AddNamedCommand (EnvDTE.AddIn AddInInstance, string Name, string ButtonText, string Tooltip, bool MSOButton, int Bitmap = 0, ref object[] ContextUIGUIDs, int vsCommandDisabledFlagsValue = 16);
abstract member AddNamedCommand : EnvDTE.AddIn * string * string * string * bool * int *  * int -> EnvDTE.Command
Public Function AddNamedCommand (AddInInstance As AddIn, Name As String, ButtonText As String, Tooltip As String, MSOButton As Boolean, Optional Bitmap As Integer = 0, Optional ByRef ContextUIGUIDs As Object(), Optional vsCommandDisabledFlagsValue As Integer = 16) As Command



Required. The AddIn that adds the new command.


Required. The short form of the name for your new command. AddNamedCommand(AddIn, String, String, String, Boolean, Int32, Object[], Int32) uses the preface Addins.Progid. to create a unique name.


Required. The name to use if the command is bound to a button that is displayed by name rather than by icon.


Required. The text displayed when a user hovers the mouse pointer over any control bound to the new command.


Required. Indicates whether the named command's button picture is an Office picture. True = button. If MSOButton is False, then Bitmap is the ID of a 16x16 bitmap resource (but not an icon resource) in a Visual C++ resource DLL that must reside in a folder with the language's locale identifier (1033 for English).


Optional. The ID of a bitmap to display on the button.


Optional. A SafeArray of GUIDs that determines which environment contexts (that is, debug mode, design mode, and so on) show the command. See vsCommandDisabledFlags..



A Command object.



You can later change the ButtonText name by responding to the QueryStatus method. If the text begins with "#", then the rest of the string is an integer that represents a resource ID in the registered satellite DLL.

The ContextUIGUIDs parameter and the vsCommandStatusValue parameter are used when the addin is not loaded and thus cannot respond to the QueryStatus method. If ContextUIGUIDs is empty, then the command is enabled until the addin is loaded and can respond to QueryStatus.

The VSPackage can receive invocation notification through the IDTCommandTarget interface. A button can be added by using the OnConnection method of the IDTExtensibility2 interface

Applies to