Pablo Galiano : Wednesday, September 03, 2008 - Posts

Subscriptions

<September 2010>
SuMoTuWeThFrSa
2930311234
567891011
12131415161718
19202122232425
262728293012
3456789

News

Subscribe to Pablo Galiano by Email

Post Categories

Wednesday, September 03, 2008 - Posts

How to open files from the Output window

My seventeenth How do I is up.

Scenario

The Visual Studio output window supports file opening. When we write to the output window a string with a specific mask, we can use the navigation buttons or double click the line and Visual Studio will open the file and position the caret in the corresponding line an column.

out.png
 

Interfaces and classes needed

 

Code snippet

    IServiceProvider serviceProvider = this;

 

    IVsOutputWindow outputwindow =

        serviceProvider.GetService(typeof(SVsOutputWindow)) asIVsOutputWindow;

    Guid generalGuidPane = VSConstants.GUID_OutWindowGeneralPane;

    IVsOutputWindowPane generalPane;

    ErrorHandler.ThrowOnFailure(outputwindow.GetPane(ref generalGuidPane, out generalPane));

 

    //MASK:

    //FilePath(#Line,#Column) : MessageToDisplay

 

    //Ex:

    //D:\Work\Temp\VSPackage4\VSPackage4\VSPackage4Package.cs(83,79) : Foo

 

    generalPane.OutputStringThreadSafe(

        string.Concat(

            @"D:\Work\Temp\VSPackage4\VSPackage4\VSPackage4Package.cs(83,79) : Foo",

            Environment.NewLine));

 

    ErrorHandler.ThrowOnFailure(generalPane.FlushToTaskList());

Assemblies needed

  • Microsoft.VisualStudio.Shell.Interop, Version=7.1.40304.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a

 

Stay tuned,

Pablo

posted Wednesday, September 03, 2008 6:57 AM by pga with 1 Comments