For VS 2012, I cannot clear the debugger output window using the following MSDN code ,
Basically, I cannot pass the DTE2 object, ClearExample .
ClearExample
public void ClearExample(DTE2 dte) { // Retrieve the Output window. OutputWindow outputWin = dte.ToolWindows.OutputWindow; // Find the "Test Pane" Output window pane; if it doesn't exist, // create it. OutputWindowPane pane = null; try { pane = outputWin.OutputWindowPanes.Item("Test Pane"); } catch { pane = outputWin.OutputWindowPanes.Add("Test Pane"); } // Show the Output window and activate the new pane. outputWin.Parent.AutoHides = false; outputWin.Parent.Activate(); pane.Activate(); // Add a line of text to the new pane. pane.OutputString("Some text." + "\r\n"); if (MessageBox.Show("Clear the Output window pane?", "", MessageBoxButtons.YesNo) == DialogResult.Yes) pane.Clear(); }
Using other SO links could not make VS2012 work.
Can I programmatically clear an Ouput window in Visual Studio?
Can I programmatically clear the Visual Studio output window (debug)?
This is how I implemented it. Check out the link to another question-answer that helped me.
' #region ClearOutputWindow /// <summary> /// Clear the Output window-pane of Visual Studio. /// Note: Causes a 1-second delay. /// </summary> public static void ClearOutputWindow() { if (!Debugger.IsAttached) { return; } //Application.DoEvents(); // This is for Windows.Forms. // This delay to get it to work. Unsure why. See http://stackoverflow.com/questions/2391473/can-the-visual-studio-debug-output-window-be-programatically-cleared Thread.Sleep(1000); // In VS2008 use EnvDTE80.DTE2 EnvDTE.DTE ide = (EnvDTE.DTE)Marshal.GetActiveObject("VisualStudio.DTE.10.0"); if (ide != null) { ide.ExecuteCommand("Edit.ClearOutputWindow", ""); Marshal.ReleaseComObject(ide); } } #endregion
Source: https://habr.com/ru/post/947243/More articles:In SQLServer 2012 TSQL, what is the difference in using XML RAW, XML AUTO and XML PATH - sqlOracle: getting links in PLSQL - pointersXHTML and not working? - htmlWhat does click.modal.data-api mean as an event name? - javascriptCalculate distance (mismatch) OpenCV - opencvCSS auto change ul width when increasing li (floating left) - htmlRead SQL statements in Hibernate - javaAdd progress to the bottom of the list - androidHow can I access Windows 8 File History programmatically? - c #Can I bypass the nearest located ancestor? - javascriptAll Articles