I print output on the console in WPF and ASP.NET-MVC applications by:
System.Diagnostics.Debug.WriteLine("text");
how to programatically clear the output window?
To display these options, open the Tools menu, click Options, expand the Debugging node, and click Output Window. General Output Settings This category contains controls that determine whether general debug messages appear in the Output window. You can specify whether each type of message appears.
To display the Output window whenever you build a project, in the Options dialog box, on the Projects and Solutions > General page, select Show Output window when build starts.
Press F11 . Visual Studio calls the Console. WriteLine(String, Object, Object) method. The console window displays the formatted string.
In Visual Studio uppermost menu choose Debug > Windows > Output. It shows all Console. WriteLine("Debug MyVariable: " + MyVariable) when you get to them.
// 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);
}
This is what I use 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 to the answers above.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With