Writing to output pane of VS2013 in C# VsPackage fails
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: Writing to output pane of VS2013 in C# VsPackage fails

  1. #1
    Join Date
    Jul 2008
    Posts
    8

    Writing to output pane of VS2013 in C# VsPackage fails

    I'm trying to write some string data to the output pane of Visual studio 2013 as part of a C# VSPackage. I've copied some tutorial code (http://msdn.microsoft.com/en-us/library/cc138529.aspx) that is meant to get the pane so you can write to it but when I run the experimental vs build in debug mode with my vspackage and trigger the button callback that calls the pane writing code the pane var that should be set in getPane is NULL and throws an exception. My overall project is pretty much just the generated template for a vspackage with no modifications besides this added bit of code.

    Code:
            /// <summary>
            /// This function is the callback used to execute a command when the a menu item is clicked.
            /// See the Initialize method to see how the menu item is associated to this function using
            /// the OleMenuCommandService service and the MenuCommand class.
            /// </summary>
            private void MenuItemCallback(object sender, EventArgs e)
            {
                // Show a Message Box to prove we were here
                IVsUIShell uiShell = (IVsUIShell)GetService(typeof(SVsUIShell));
                Guid clsid = Guid.Empty;
                int result;
    
                  var outputWindow = GetService(
                    typeof(SVsOutputWindow)) as IVsOutputWindow;
                IVsOutputWindowPane pane;
                Guid guidGeneralPane =
                    VSConstants.GUID_OutWindowGeneralPane;
                outputWindow.GetPane(ref guidGeneralPane, out pane);
    
                string msg = "WRITING TO OUTPUT PANE\n";
    
                pane.OutputString(msg);
           }
    Anyone know why this is happening?

  2. #2
    Join Date
    Jul 2008
    Posts
    8

    Re: Writing to output pane of VS2013 in C# VsPackage fails

    Well just an update, it seems to work fine when writing specifically to the BUILD output pane or creating my own, just not to the general output.

    Code:
                Guid guidGeneralPane =
                    VSConstants.GUID_BuildOutputWindowPane; // works 
                outputWindow.GetPane(ref guidGeneralPane, out pane);
    Code:
            IVsOutputWindowPane CreatePane(Guid paneGuid, string title,
        bool visible, bool clearWithSolution)
            {
                IVsOutputWindow output =
                    (IVsOutputWindow)GetService(typeof(SVsOutputWindow));
                IVsOutputWindowPane pane;
    
                // Create a new pane.
                output.CreatePane(
                    ref paneGuid,
                    title,
                    Convert.ToInt32(visible),
                    Convert.ToInt32(clearWithSolution));
    
                // Retrieve the new pane.
                output.GetPane(ref paneGuid, out pane);
    
                return pane;
            }
    
            /// <summary>
            /// This function is the callback used to execute a command when the a menu item is clicked.
            /// See the Initialize method to see how the menu item is associated to this function using
            /// the OleMenuCommandService service and the MenuCommand class.
            /// </summary>
            private void MenuItemCallback(object sender, EventArgs e)
            {
                // Show a Message Box to prove we were here
                IVsUIShell uiShell = (IVsUIShell)GetService(typeof(SVsUIShell));
                Guid clsid = Guid.Empty;
                int result;
    
                Guid g = new Guid("0A3A19C1-FE4A-4A49-988C-0CC8E478203A");
    
                IVsOutputWindowPane pane;
                pane = CreatePane(g, "PANE", true, true);
    
                pane.Activate();
    
                string msg = "WRITING TO OUTPUT PANE\n";
    
                pane.OutputString(msg);
            }

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center