Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / August 2005

Tip: Looking for answers? Try searching our database.

How to get debugging output in .Net

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Richard Lionheart - 30 Aug 2005 01:16 GMT
Hi All,

I'm creating a web-forms app using Prosise's "Programming MS .Net" (2002).
He had a try block (on p. 208) followed by:

catch (FormatException e)
{
   Output.Text("Error");
}

The only namespace he imported was System.Data.

I tried the same thing,  but the compiler didn't like "Output."   Could that
be because I'm running .Net 1.1,  where his book was no doubt based on 1.0?

Then I tried System.Diagnostics.Trace.WriteLine ("Starting Page_Load"); but
couldn't find that text anywhere,  not on the Client window nor in the
Output | Debug pane.

I haven't written MSVC++ in years,  but I miss my Debug.Output (or whatever
I did back then).

Any ideas,

TIA,
Ricard
Lau Lei Cheong - 30 Aug 2005 04:27 GMT
I'm not writting C++ projects, but I prefer to use
System.Console.Error.Write()/WriteLine() to output console debug messages.
(And I suspect this will also work for winform, where in debug mode it'll
write into "Output" window)

"Richard Lionheart" <NoOne@Nowhere.net> ¼¶¼g©ó¶l¥ó·s»D:OZliTgPrFHA.2880@TK2MSFTNGP12.phx.gbl...
> Hi All,
>
[quoted text clipped - 23 lines]
> TIA,
> Ricard
Richard Lionheart - 30 Aug 2005 20:22 GMT
Hi Lau Lei ,

Thank you for your help.  As you may notice,  I got a response from Michael:

     Use Debug.WriteLine() from System.Diagnostics

I think his syntax means less typing for me,  so I think I'm going to adopt
his idea.

Best wishes,
Richard

> I'm not writting C++ projects, but I prefer to use
> System.Console.Error.Write()/WriteLine() to output console debug messages.
[quoted text clipped - 30 lines]
>> TIA,
>> Ricard
Michael Nemtsev - 30 Aug 2005 09:01 GMT
Hello Richard,

Use Debug.WriteLine() from System.Diagnostics

RL> I haven't written MSVC++ in years,  but I miss my Debug.Output (or
RL> whatever I did back then).

---
WBR,
Michael  Nemtsev
Richard Lionheart - 30 Aug 2005 20:05 GMT
Hi Michael,

Thanks for the correct syntax.  But I've still got a newbie problem.

What I've got is code shown below,  with the HTML content snipped (it works
and produces an array of labels on the Client machine).  My main problem is
failure to understand why output from the WriteLine in Page_Load does not
seem to appear in my Output | Debug pane.

Maybe that code shouldn't run at the Server,  but that's the way Prosise
wrote the example that my code is loosely based upon.

Any ideas?  Again:

TIA,
Richard

=============
%@ Import Namespace=System.Data%>
<%@ Page language="c#" Codebehind="MainForm.aspx.cs" AutoEventWireup="false"
Inherits="MyVirtualDir.WebForm1" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
    <!-- Head and body code that creates a matrix of labels colored
differently on the client machine -->
</HTML>
<script language="C#" runat="server">
void Page_Load (Object sender, EventArgs e)
{
     System.Diagnostics.Debug.WriteLine ("Starting Page_Load");
     try
    {
            // If this isn't a PostBack, add items to a listbox
            if (!IsPostBack)
            {
                       DataSet ds = new DataSet();
                       ds.ReadXml( Server.MapPath("Sites.xml") );
                       foreach (DataRow row in ds.Tables[0].Rows)
                        SitesListBox.Items.Add (
row["SiteData"].ToString() );
                       SitesListBox.SelectedIndex = 0;
            }
 }
 catch (Exception ex)
 {
            System.Diagnostics.Debug.WriteLine ("Error");
 }
}
</script>
======
Michael Nemtsev - 30 Aug 2005 20:50 GMT
Hello Richard,

To give an answer why smth is not working to put a breakpoint and test :)

What's the idea of using Output window in your code?
If u would like to log you app, then u need to use specific tools.
I recomed to look at "log4net" and "Microsoft Enterprise Library"
Both of them gives u a powefull way to log your apps

RL> Hi Michael,
RL> What I've got is code shown below,  with the HTML content snipped
RL> (it works and produces an array of labels on the Client machine).
RL> My main problem is failure to understand why output from the
RL> WriteLine in Page_Load does not seem to appear in my Output | Debug
RL> pane.

WBR,
Michael  Nemtsev
"At times one remains faithful to a cause only because its opponents do not
cease to be insipid. (c) Friedrich Nietzsche
Richard Lionheart - 31 Aug 2005 16:14 GMT
> ... put a breakpoint and test :)

Great answer.  I'm a retired software engineer,  so while I have programmed
a lot with Visual C++,  I never had any clients who wanted to switch to .Net
... hence no .Net experience.  And after not programming for a few years,  I
simply forgot how to develop software.  In particular,  I forgot about
setting breakpoints and stepping through code,  so I really needed your
"kick in the butt" to get me going again.  Thanks for that!!

> What's the idea of using Output window in your code?

I cannibalized an example from Jeff Prosise's "Programming Microsoft .Net"
(2002) that I knew should have failed but didn't seem to.  In desperation,
I tried getting some kind of feedback.  But I'll be OK now with breakpoints,
etc.

> ... "log4net" and "Microsoft Enterprise Library"

Excellent sites!  I'll use them a lot.

> "At times one remains faithful to a cause only because its opponents do
> not cease to be insipid. (c) Friedrich Nietzsche"

BTW,  I always liked Nietzsche,  but I don't remember what stuff of his I
read.

Again, thank you very much for taking the time to help me out of my rut.

Very best wishes,
Richard Muller

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.