O'Reilly logo

Microsoft Visual Studio 2015 Unleashed, Third Edition by Mike Snell, Lars Powers

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Executing a Command

You can execute commands in two ways. The DTE object has an ExecuteCommand method you can use to trigger a command based on its name.

_applicationObject.ExecuteCommand("Window.CloseDocumentWindow");

The Commands collection is also a vehicle for launching commands through its Raise method. Instead of using the command’s name, the Raise method uses its GUID and ID to identify the command.

Commands2 commands = (Commands2)_applicationObject.Commands;Command cmd = commands.Item["Window.CloseDocumentWindow"];object customIn;object customOut;commands.Raise(cmd.Guid, cmd.ID, customin, customout);

Some commands accept arguments. The Shell command is one example. It is used ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required