Package with Simple menu commands

This package demonstrates the simplicity of code required for a simple command displaying a message box in VSXtra.

Points of Interest:

  • Everything uses declarative approach
  • Command handling requires only a simple method decorated with attributes.
  • CommandExecMethod signs that the method is to be executed as a response for a command.
  • The CommandId attribute defines how the command is bound to the method.
  • The command has a ShowMessageAction attribute defines a menu action declaratively.
Package source code:

using System.Runtime.InteropServices;
using Microsoft.VisualStudio.Shell;
using VSXtra;

namespace DeepDiver.ShowMessage
  [PackageRegistration(UseManagedResourcesOnly = true)]
  [InstalledProductRegistration(false, "#110", "#112", "1.0", IconResourceID = 400)]
  [ProvideLoadKey("Standard", "1.0", "ShowMessage", "DeepDiver", 1)]
  [ProvideMenuResource(1000, 1)]
  public sealed class ShowMessagePackage : PackageBase
    [CommandId(GuidList.guidShowMessageCmdSetString, CmdIDs.cmdidDisplayMyMessage)]
    [ShowMessageAction("Hello, World from ShowMessagePackage")]
    private static void DisplayMessage()


Last edited Aug 26, 2008 at 5:12 AM by INovak, version 3


No comments yet.