How to programmatically clear output in Visual Studio 2013

I print console output in WPF and ASP.NET-MVC applications:

System.Diagnostics.Debug.WriteLine("text"); 

How to programmatically clear the output window?

+5
source share
3 answers
 // Import EnvDTE and EnvDTE80 into your project using EnvDTE; using EnvDTE80; protected void ClearOutput() { DTE2 ide = (DTE2)System.Runtime.InteropServices.Marshal.GetActiveObject("VisualStudio.DTE.12.0"); ide.ToolWindows.OutputWindow.OutputWindowPanes.Item("Debug").Clear(); System.Runtime.InteropServices.Marshal.ReleaseComObject(ide); } 
+3
source

Inside the core APIs, debugging output is only a stream only forward - you should not assume that it is available only in Visual Studio . The debug output can only be written by the application, and if you need more detailed control, it should be displayed in the user interface of your application (whether it be a console window that can be cleared or a WinForms or WPF application, etc.)

0
source

This is what I was in VS2013, Win10, x64:

 private static void ClearVS2013DebugWindow() { // add reference to "C:\Program Files (x86)\Common Files\microsoft shared\MSEnv\PublicAssemblies\envdte.dll" EnvDTE.DTE ide = (EnvDTE.DTE)System.Runtime.InteropServices.Marshal.GetActiveObject("VisualStudio.DTE.12.0"); if (ide != null) { ide.ExecuteCommand("Edit.ClearOutputWindow", ""); System.Runtime.InteropServices.Marshal.ReleaseComObject(ide); } } 

Credit for the answers above.

0
source

Source: https://habr.com/ru/post/1201655/


All Articles