2013-06-13 6 views
6

स्पष्ट करने के वी.एस. 2012 के लिए, मैं निम्नलिखित MSDN code का उपयोग कर डिबगर उत्पादन खिड़की साफ करने के लिए,कैसे डिबगर उत्पादन खिड़की Visual Studio 2012

मूल रूप से मैं ClearExample को, DTE2 वस्तु पारित करने में सक्षम नहीं कर रहा हूँ में सक्षम नहीं हूँ।

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(); 
} 

अन्य SO लिंक का उपयोग करके यह VS2012 के लिए काम नहीं कर सका।

Is it possible to programmatically clear the Ouput Window in Visual Studio?

Can the Visual Studio (debug) Output window be programatically cleared?

उत्तर

4

यहाँ कैसे मैं इसे लागू किया है। किसी अन्य प्रश्न-उत्तर के संदर्भ पर ध्यान दें जो मेरी मदद करता है।

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

संदर्भ EnvDTE जोड़ें: VS10 के लिए: C: \ प्रोग्राम फ़ाइलें (x86) \ माइक्रोसॉफ्ट विजुअल स्टूडियो 10.0 \ Common7 \ IDE \ PublicAssemblies \ EnvDTE.dll – mvermand

+0

मेरी 64-बिट सिस्टम पर (विंडोज 10 विजुअल स्टूडियो 2015 के साथ) 'EnvDTE.dll' पथ 'सी: \ प्रोग्राम फ़ाइलें (x86) \ सामान्य फ़ाइलें \ Microsoft साझा \ MSEnv \ PublicAssemblies' के अंतर्गत स्थित था। –

संबंधित मुद्दे