Output window
To write to the "General" output window in Visual Studio, you need to do the following:
IVsOutputWindow outWindow = Package.GetGlobalService( typeof( SVsOutputWindow ) ) as IVsOutputWindow; Guid generalPaneGuid = VSConstants.GUID_OutWindowGeneralPane; // PS There also the GUID_OutWindowDebugPane available. IVsOutputWindowPane generalPane; outWindow.GetPane( ref generalPaneGuid , out generalPane ); generalPane.OutputString( "Hello World!" ); generalPane.Activate(); // Brings this pane into view
If you want to write to a custom window, this is what you need to do:
IVsOutputWindow outWindow = Package.GetGlobalService( typeof( SVsOutputWindow ) ) as IVsOutputWindow; // Use eg Tools -> Create GUID to make a stable, but unique GUID for your pane. // Also, in a real project, this should probably be a static constant, and not a local variable Guid customGuid = new Guid("0F44E2D1-F5FA-4d2d-AB30-22BE8ECD9789"); string customTitle = "Custom Window Title"; outWindow.CreatePane( ref customGuid, customTitle, 1, 1 ); IVsOutputWindowPane customPane; outWindow.GetPane( ref customGuid, out customPane); customPane.OutputString( "Hello, Custom World!" ); customPane.Activate(); // Brings this pane into view
Details on IVsOutputWindow and IVsOutputWindowPane can be found on MSDN.
Error list
To add items to the error list, IVsSingleFileGenerator has a call to the void Generate(...) method, which has a parameter of type IVsGeneratorProgress . This interface has a void GeneratorError() method that allows you to report errors and warnings to the Visual Studio error list.
public class MyCodeGenerator : IVsSingleFileGenerator { ... public void Generate( string inputFilePath, string inputFileContents, string defaultNamespace, out IntPtr outputFileContents, out int output, IVsGeneratorProgress generateProgress ) { ... generateProgress.GeneratorError( false, 0, "An error occured", 2, 4); ... } ... }
Details of GeneratorError () can be found on MSDN.
Alex Dec 05 '09 at 15:53 2009-12-05 15:53
source share