Skip to content

How do I get IMenuCommandService? #349

Answered by reduckted
LadyCailin asked this question in Q&A
Discussion options

You must be logged in to vote

The IMenuCommandService can only be retrieved from a VSPackage or tool window (see #92 (comment)).

So in your package class, instead of calling this:

commandService = await VS.GetServiceAsync<IMenuCommandService, IMenuCommandService>();
// ❌ Will throw an exception.

You instead need to call this:

commandService = await this.GetServiceAsync<IMenuCommandService, IMenuCommandService>();

Replies: 1 comment 6 replies

Comment options

You must be logged in to vote
6 replies
@reduckted
Comment options

@LadyCailin
Comment options

@LadyCailin
Comment options

@reduckted
Comment options

@LadyCailin
Comment options

Answer selected by LadyCailin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants