visual studio - Can I pass an argument/switch/parameter to a VSPackage MenuCommand? -


i hoping here might able me out this. i'm not experienced programmer i'm making progress on project.

i've got need programmatically interact visual studio. success has been had using envdte interop stuff, seems of need needs done inside vs i'm attempting utilize vspackage menucommand various things. sorry vagueness.

i'm creating custom menucommand vspackage extension, , able trigger menucommand programmatically application using dte.

what i'm wondering is: possible define menucommand can take arguments passed along triggering external application?

using vs package template in visual studio 2012 using menu command option, code lives inside method:

private void menuitemcallback(object sender, eventargs e)     {         // code...     } 

there lot of other auto-generated code plumbing together, code lives in method. there way alter method allow parameters passed it? other changes must make other files declare/register differently-functioning method once (if can)?

for example:

static void main(string[] args)     {     type visualstudiotype = type.gettypefromprogid("visualstudio.dte.11.0");     dte dte = activator.createinstance(visualstudiotype) dte;     dte.mainwindow.visible = true;     dte.executecommand("mycommand");         } 

this works. i'd change last command to:

dte.executecommand("mycommand", "myarguments"); 

when attempt this, receive following exception: "command \"mycommand\" not accept arguments or switches."

sorry if i'm not being clear. appreciated.

commands created add-ins accept parameters default.

commands created packages need specify <commandflag>allowparams</commandflag> when defining command in .vsct file. see: http://msdn.microsoft.com/en-us/library/bb491716.aspx

and see thread:

iolecomandtarget::exec commands parameters https://social.msdn.microsoft.com/forums/en-us/134983e8-049c-40e1-a212-312fa637698b/iolecomandtargetexec-for-commands-with-parameters?forum=vsx

then, should work, either using dte.executecommand or dte.commands.raise(...). see:

howto: pass parameters programmatically command visual studio add-in http://www.visualstudioextensibility.com/articles/add-ins/


Comments

Popular posts from this blog

python - mat is not a numerical tuple : openCV error -

c# - MSAA finds controls UI Automation doesn't -

wordpress - .htaccess: RewriteRule: bad flag delimiters -