2013-06-13 13 views

Antwort

4

Hier ist, wie ich es umgesetzt. Beachten Sie den Hinweis auf eine andere Frage - Antwort, die mir geholfen hat.

' #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 

'

+0

Referenz EnvDTE hinzufügen: für VS10: C: \ Program Files (x86) \ Microsoft Visual Studio 10.0 \ Common7 \ IDE \ Public \ EnvDTE.dll – mvermand

+0

Auf meinem 64-Bit-System (Windows 10 mit Visual Studio 2015) "EnvDTE.dll" befand sich unter dem Pfad 'C: \ Programme (x86) \ Gemeinsame Dateien \ Microsoft Shared \ MSEnv \ PublicAssemblies'. –