Sam's Blog

25 Nov

MEF support for the Output Window in Visual Studio 2010

As some people have noticed, the Visual Studio 2010 SDK doesn’t have great support for the Output Window from MEF extensions. This post aims to change that. Like several other components I’m writing about, I hope to provide this one in a “general extensibility helper” that could be installed separately from extensions that use it so its features can be shared among them.

There are a couple goals here:

  • Provide a service for accessing the output window panes
  • Provide a simple method of creating new output window panes

I’ll start with the usage (since that’s the interface people will normally see) and follow it with the implementation.

Defining an output window pane

Now this is easy.

Using an output window

First you import the IOutputWindowService:

Then you use it to get an output window, which you can write to:

If you want to write to one of the standard panes, pass one of the following to TryGetPane:

The IOutputWindowPane and IOutputWindowService interfaces

The internal implementation

Finally, one extension method that’s used to help with the IOleServiceProvider

Leave a Reply

© 2024 Sam's Blog | Entries (RSS) and Comments (RSS)

Your Index Web Directorywordpress logo