Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Clear Output/Debug window?

291 views
Skip to first unread message

Bob

unread,
Mar 22, 2007, 6:46:50 AM3/22/07
to

Does anyone know how to clear the window so it's easier to see the
stuff you have listed with Debug.Write(xyz)?

Bob Sweeney

Peter Bromberg [C# MVP]

unread,
Mar 22, 2007, 7:21:10 AM3/22/07
to
Try right-clicking inside the Output window and look at the context menu
options.
Peter
--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net

Bob

unread,
Mar 22, 2007, 7:49:00 AM3/22/07
to
On Mar 22, 12:21 pm, Peter Bromberg [C# MVP]
> > Bob Sweeney- Hide quoted text -
>
> - Show quoted text -

I mean programmatically so I can see my Debug.Write results


Peter Bromberg [C# MVP]

unread,
Mar 22, 2007, 7:00:21 PM3/22/07
to
Programmatically, you need to work with the DTE80 assembly which comes in
either COM or .NET flavors. I don't know exactly how to do it, but there are
plenty of code samples on MSDN to get you started.

Zytan

unread,
Mar 22, 2007, 8:41:33 PM3/22/07
to
> Does anyone know how to clear the window so it's easier to see the
> stuff you have listed with Debug.Write(xyz)?

You can't programmatically. I know, it sucks. Best to make a logger
and use that instead. Although, sometimes the Output window info is
useful, so its not a complete waste. But, for general debugging it
pretty much is.

I wonder if you can just create a console, like in Win32 apps? And
use that? That'd be the easiest solution, I imagine. But, last I
heard you couldn't instantiate Console in .NET 2.0 or later.

Zytan

Peter Bromberg [C# MVP]

unread,
Mar 23, 2007, 5:53:03 AM3/23/07
to
Zytan,
This is inaccurate. With the EnvDTE80 namespace you have programmatic access
to all of the IDE, its windows, and their contents:

http://msdn2.microsoft.com/en-us/library/0e105c68(VS.80).aspx
http://msdn2.microsoft.com/en-us/library/envdte(VS.80).aspx

-- Peter

Laura T.

unread,
Mar 23, 2007, 10:32:46 AM3/23/07
to
Yup. This works. But is it worth of it?

private void ClearOutput()
{
EnvDTE80.DTE2 ide =
(EnvDTE80.DTE2)System.Runtime.InteropServices.Marshal.GetActiveObject("VisualStudio.DTE.8.0");
ide.ExecuteCommand("Edit.ClearOutputWindow","");
System.Runtime.InteropServices.Marshal.ReleaseComObject(ide);
}

"Peter Bromberg [C# MVP]" <pbro...@yahoo.yabbadabbadoo.com> ha scritto nel
messaggio news:E4C7A3F8-3ADA-4B00...@microsoft.com...

Zytan

unread,
Mar 23, 2007, 12:50:40 PM3/23/07
to
> This is inaccurate. With the EnvDTE80 namespace you have programmatic access
> to all of the IDE, its windows, and their contents:
>
> http://msdn2.microsoft.com/en-us/library/0e105c68(VS.80).aspxhttp://msdn2.microsoft.com/en-us/library/envdte(VS.80).aspx

I thought you could, but not from C#, which is what I meant. But, I
see that you can from C#, as Laura has shown with the content you
provided.

Zytan

Zytan

unread,
Mar 23, 2007, 12:53:06 PM3/23/07
to
> Yup. This works. But is it worth of it?
>
> private void ClearOutput()
> {
> EnvDTE80.DTE2 ide =
> (EnvDTE80.DTE2)System.Runtime.InteropServices.Marshal.GetActiveObject("Visu­alStudio.DTE.8.0");

> ide.ExecuteCommand("Edit.ClearOutputWindow","");
> System.Runtime.InteropServices.Marshal.ReleaseComObject(ide);
> }

Thanks for the example, Laura.

What do you imply by your question? I have one question, and maybe
this is what you are getting at: Is there any reason why the Output
Windows is NOT cleared? I'd prefer it cleared every time. Oh, wait,
I think I know why: because you'll clear the start-up logging of the
process. We actually want it to be cleared BEFORE that, so that only
the current run is shown in the window. Yeah, so this is why it is
likely not worth it. And thus, a logger is a better idea.

Zytan

Zytan

unread,
Mar 23, 2007, 2:20:40 PM3/23/07
to
> We actually want it to be cleared BEFORE that, so that only
> the current run is shown in the window.

Actually, only the current execution is shown in the Output Window.
So all is ok.

I was certain that before this wasn't the case. I think I was
thinking about how it works in VB, which is quite different.

Zytan

Pete Nolastname

unread,
Sep 28, 2010, 11:06:27 AM9/28/10
to
I couldn't get this code to work in VS2008, but when I changed the string "VisualStudio.DTE.8.0" to "VisualStudio.DTE.9.0" it worked like a champ!

Thanks!

> On Thursday, March 22, 2007 5:46 AM Bob wrote:

> Does anyone know how to clear the window so it is easier to see the


> stuff you have listed with Debug.Write(xyz)?
>

> Bob Sweeney


>> On Thursday, March 22, 2007 6:21 AM pbromber wrote:

>> Try right-clicking inside the Output window and look at the context menu
>> options.
>> Peter
>> --

>> Site: http://www.eggheadcafe.com
>> UnBlog: http://petesbloggerama.blogspot.com
>> Short urls & more: http://ittyurl.net
>>
>>
>>
>>

>> "Bob" wrote:


>>> On Thursday, March 22, 2007 6:49 AM Bob wrote:

>>> I mean programmatically so I can see my Debug.Write results


>>>> On Thursday, March 22, 2007 6:00 PM pbromber wrote:

>>>> Programmatically, you need to work with the DTE80 assembly which comes in
>>>> either COM or .NET flavors. I don't know exactly how to do it, but there are
>>>> plenty of code samples on MSDN to get you started.
>>>> Peter
>>>> --

>>>> Site: http://www.eggheadcafe.com
>>>> UnBlog: http://petesbloggerama.blogspot.com
>>>> Short urls & more: http://ittyurl.net
>>>>
>>>>
>>>>
>>>>

>>>> "Bob" wrote:


>>>>> On Thursday, March 22, 2007 7:41 PM Zytan wrote:

>>>>> You can't programmatically. I know, it sucks. Best to make a logger
>>>>> and use that instead. Although, sometimes the Output window info is
>>>>> useful, so its not a complete waste. But, for general debugging it
>>>>> pretty much is.
>>>>>
>>>>> I wonder if you can just create a console, like in Win32 apps? And
>>>>> use that? That'd be the easiest solution, I imagine. But, last I
>>>>> heard you couldn't instantiate Console in .NET 2.0 or later.
>>>>>
>>>>> Zytan


>>>>>> On Friday, March 23, 2007 4:53 AM pbromber wrote:

>>>>>> Zytan,
>>>>>> This is inaccurate. With the EnvDTE80 namespace you have programmatic access
>>>>>> to all of the IDE, its windows, and their contents:
>>>>>>
>>>>>> http://msdn2.microsoft.com/en-us/library/0e105c68(VS.80).aspx
>>>>>> http://msdn2.microsoft.com/en-us/library/envdte(VS.80).aspx
>>>>>>
>>>>>>
>>>>>>
>>>>>> -- Peter
>>>>>> Site: http://www.eggheadcafe.com
>>>>>> UnBlog: http://petesbloggerama.blogspot.com
>>>>>> Short urls & more: http://ittyurl.net
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> "Zytan" wrote:


>>>>>>> On Friday, March 23, 2007 9:32 AM Laura T. wrote:

>>>>>>> Yup. This works. But is it worth of it?
>>>>>>>
>>>>>>> private void ClearOutput()
>>>>>>> {
>>>>>>> EnvDTE80.DTE2 ide =
>>>>>>> (EnvDTE80.DTE2)System.Runtime.InteropServices.Marshal.GetActiveObject("VisualStudio.DTE.8.0");
>>>>>>> ide.ExecuteCommand("Edit.ClearOutputWindow","");
>>>>>>> System.Runtime.InteropServices.Marshal.ReleaseComObject(ide);
>>>>>>> }
>>>>>>>
>>>>>>> "Peter Bromberg [C# MVP]" <pbro...@yahoo.yabbadabbadoo.com> ha scritto nel
>>>>>>> messaggio news:E4C7A3F8-3ADA-4B00...@microsoft.com...


>>>>>>>> On Friday, March 23, 2007 11:50 AM Zytan wrote:

>>>>>>>> I thought you could, but not from C#, which is what I meant. But, I
>>>>>>>> see that you can from C#, as Laura has shown with the content you
>>>>>>>> provided.
>>>>>>>>
>>>>>>>> Zytan


>>>>>>>>> On Friday, March 23, 2007 11:53 AM Zytan wrote:

>>>>>>>>> su=ADalStudio.DTE.8.0");


>>>>>>>>>
>>>>>>>>> Thanks for the example, Laura.
>>>>>>>>>
>>>>>>>>> What do you imply by your question? I have one question, and maybe
>>>>>>>>> this is what you are getting at: Is there any reason why the Output
>>>>>>>>> Windows is NOT cleared? I'd prefer it cleared every time. Oh, wait,
>>>>>>>>> I think I know why: because you'll clear the start-up logging of the
>>>>>>>>> process. We actually want it to be cleared BEFORE that, so that only
>>>>>>>>> the current run is shown in the window. Yeah, so this is why it is
>>>>>>>>> likely not worth it. And thus, a logger is a better idea.
>>>>>>>>>
>>>>>>>>> Zytan


>>>>>>>>>> On Friday, March 23, 2007 1:20 PM Zytan wrote:

>>>>>>>>>> Actually, only the current execution is shown in the Output Window.
>>>>>>>>>> So all is ok.
>>>>>>>>>>
>>>>>>>>>> I was certain that before this wasn't the case. I think I was
>>>>>>>>>> thinking about how it works in VB, which is quite different.
>>>>>>>>>>
>>>>>>>>>> Zytan


>>>>>>>>>> Submitted via EggHeadCafe - Software Developer Portal of Choice
>>>>>>>>>> Simple .NET HEX PixelColor Utility
>>>>>>>>>> http://www.eggheadcafe.com/tutorials/aspnet/5617a491-963d-4510-b8f1-1863ddf52bc1/simple-net-hex-pixelcolor-utility.aspx

Pete Nolastname

unread,
Sep 28, 2010, 11:10:14 AM9/28/10
to
Before this code will work, you have to right click on "References" in your Solution Explorer and select "Add Reference".

Select both "EnvDTE" and "EnvDTE80"

That's it!

Submitted via EggHeadCafe - Software Developer Portal of Choice

ASP.NET HttpPostedFile Image Resizer
http://www.eggheadcafe.com/tutorials/aspnet/ba8d2418-6d67-40f7-989c-e90688058778/aspnet-httppostedfile-image-resizer.aspx

0 new messages