Writing to the Immediate window

Sheesh, this new Debug class and its Listeners confusion...how the heck do I just write output to my good old Immediate window...or the just-as-handy equivalent of an Immediate window?
brykerAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
DarthPedroConnect With a Mentor Commented:
If you just use the Trace object, it will write to the Debug window (or what used to be the Immediate window in VB6).  Something like this should work:

System.Diagnostics.Trace.WriteLine("Testing Trace output");

This is assuming that you are writing a WinForms app.  For ASP.NET, you Page object has a Trace method, so use that instead.  The ASP.NET trace doesn't go to the Debug Window, but goes onto the page itself (tacked on to the end).

To enable viewing of debug comments and such on an ASP.NET page, you need to add Trace="true" to the top-level page directive, like this:
<%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false" Inherits="EETestApps.WebForm1" trace="true"%>
0
 
brykerAuthor Commented:
Great.  Thanks.

One more thing--I've found lately (in hunting for the elusive Cache object) that since I'm just doing Web Methods on a Web Service, I don't have a lot of things available to me.  One would be this Page object.

Do you know how you'd write to the Immediate window from a Web Method?

You've answered my question already, so I'm not trying to change the rules on you.  Just wondering.
0
 
DarthPedroCommented:
Using the following code for a Web Service method, I was able to output the trace string to the Debug window (just like it worked for a WinForms app):

[WebMethod]
public string HelloWorld()
{
     System.Diagnostics.Trace.WriteLine("Testing the WebMethod trace...");
     return "Hello World";
}
0
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

 
brykerAuthor Commented:
Awesome.  Thank you.
0
 
brykerAuthor Commented:
Dude, this doesn't work.  Not for WinForms, not for WebMethods.  I don't know where these strings are going, but it's not to my Command Window.
0
 
DarthPedroCommented:
It's not the command window it's the debug output window.  You can activate it from the main menu under View > Other Windows > Output.
0
 
brykerAuthor Commented:
My bad.  You're right, there it is.  I could use a course in just how to dock all these windows so that I can see them and make sense of them.
0
 
DarthPedroCommented:
:)
yeah, there's more windows than space on my monitor...
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.