0

I'm implementing a Microsoft.VisualStudio.Shell.Package that adds a command in the context menu, when a Solution Explorer item is clicked.

The code that adds the command looks something like this:

_oleMenuCommandService = GetService(typeof (IMenuCommandService)) as OleMenuCommandService;
if (_oleMenuCommandService != null)
{
    var menuCommandId = new CommandID(GuidList.guidErsx_Net_VsixCmdSet, (int) PkgCmdIDList.sortResx);
    var menuItem = new OleMenuCommand(MenuItemClick, StatusChanged, BeforeContextMenuOpens, menuCommandId);
    _oleMenuCommandService.AddCommand(menuItem);
}

The package is defined like this:

[PackageRegistration(UseManagedResourcesOnly = true)]
[InstalledProductRegistration("#110", "#112", "1.0", IconResourceID = 400)]
[ProvideMenuResource("Menus.ctmenu", 1)]
[Guid(GuidList.guidErsx_Net_VsixPkgString)]
[ProvideAutoLoad(VSConstants.UICONTEXT.SolutionExistsAndFullyLoaded_string)]

The command shows when any Solution Explorer item is right clicked, except any of the following:

  • The item is under a website project
  • The item is a csproj file
  • The item is a folder

In these cases the events defined above are not fired at all.

How can I cover these cases as well? Do I need to register something somewhere?

seldary
  • 6,186
  • 4
  • 40
  • 55
  • You should post your .vsct file, it's the most important piece of information when a command doesn't show on the expected menu, context menu or toolbar – Carlos Quintero Apr 25 '15 at 18:43
  • Forgot about that one.. I eventually marked this as a duplicate, finding that I should have added IDM_VS_CTXT_WEBITEMNODE as another parent. – seldary Apr 26 '15 at 07:05

0 Answers0