Problem with Visual Studio menu entry event handler in PowerShell -
i try menu entry in visual studio using powershell in nuget console or power console. these powershell hosts run in context of visual studio. got somewhere, not far enough... menu entry appears (right-click on solution), can't event handler connected...
my code:
pm> $sol = $dte.commandbars | where-object { $_.name -like 'solution' } pm> $menuitem = $sol.controls.add([microsoft.visualstudio.commandbars.msocontroltype]::msocontrolbutton, 1, "", 1, $true) pm> $menuitem.caption = "action nuget" pm> $menuitemhandler = $dte.events.commandbarevents($menuitem) pm> $commandbarevents = get-interface $menuitemhandler ([envdte._dispcommandbarcontrolevents_event]) pm> $commandbarevents.add_click([envdte._dispcommandbarcontrolevents_clickeventhandler]{write-host “clicked”}) cannot convert value "write-host “clicked”" type "envdte._dispcommandbarcontrolevents_clickeventhandler". error: "the type 'system.boolean&' may not used type argument." @ line:1 char:84 + $commandbarevents.add_click([envdte._dispcommandbarcontrolevents_clickeventhandler] <<<< {write-host “clicked”}) + categoryinfo : notspecified: (:) [], runtimeexception + fullyqualifiederrorid : runtimeexception pm>
the last line gives trouble...
i patterned after code executed nuget in nuget.psm1:
# hook solution events $solutionevents = get-interface $dte.events.solutionevents ([envdte._dispsolutionevents_event]) $solutionevents.add_opened([envdte._dispsolutionevents_openedeventhandler]{ executeinitscripts updateworkingdirectory }) $solutionevents.add_afterclosing([envdte._dispsolutionevents_afterclosingeventhandler]{ updateworkingdirectory })
any ideas on how eventhandler connected?
Comments
Post a Comment