Results 1 to 12 of 12

Thread: debug.writeline or trace.writeline -- no output

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jan 2012
    Posts
    122

    debug.writeline or trace.writeline -- no output

    Hi

    in VS 2008, I started a new VB console project, using default options. I wrote this simple program:

    Module Module1

    Sub Main()
    Dim ArrayOfInts() As Integer

    ArrayOfInts = New Integer() {1, 2, 3, 4, 5, 6, 7, 8, 9}

    For i = 0 To ArrayOfInts.Length - 1
    Debug.WriteLine(ArrayOfInts(i))
    Trace.WriteLine(ArrayOfInts(i))
    Next
    End Sub
    End Module

    ...then ran it under debug (I just hit F5)

    However, I cannot find the output from the calls to writeline. Not in the Output window, not in the Immediate window and not in the console output. So...where is it going?

    Or, do I need to do something extra to get these to appear?

  2. #2
    PowerPoster
    Join Date
    Mar 2002
    Location
    UK
    Posts
    4,780

    Re: debug.writeline or trace.writeline -- no output

    You won't see anything in the Console unless you use the Console.xx methods. You can divert output to the immediate window (or vice-versa) and you also have options when you right click in the output/immediate to show/hide certain things, like exceptions and likely debug lines, check you have not turned them off by accident.

  3. #3
    Karen Payne MVP kareninstructor's Avatar
    Join Date
    Jun 2008
    Location
    Oregon
    Posts
    6,714

    Re: debug.writeline or trace.writeline -- no output

    When writing to the Console as shown below and pressing F5 or select Debug to the your console app the console window will appear as a flash. To stop this add a Console.ReadLine or press CTRL+F5 which causes the console app to wait for you to press the a key to continue.

    Code:
    Module Module1
        Sub Main()
            Console.WriteLine("See me")
        End Sub
    End Module

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Jan 2012
    Posts
    122

    Re: debug.writeline or trace.writeline -- no output

    Quote Originally Posted by Grimfort View Post
    You won't see anything in the Console unless you use the Console.xx methods. You can divert output to the immediate window (or vice-versa) and you also have options when you right click in the output/immediate to show/hide certain things, like exceptions and likely debug lines, check you have not turned them off by accident.
    Yeah I get that about the console methods. If I add console.writeline (blabla), I see that as expected.

    I am completely unsuccessful in getting any output from the debug.writeline or trace.writeline methods to appear anywhere though. The Immediate and Output windows are empty.

    Note that I started a brand new project for this test and left all options at their default settings. I didn't turn any options off by accident.

  5. #5
    PowerPoster
    Join Date
    Mar 2002
    Location
    UK
    Posts
    4,780

    Re: debug.writeline or trace.writeline -- no output

    They are not project settings, they are IDE settings.

  6. #6

    Thread Starter
    Lively Member
    Join Date
    Jan 2012
    Posts
    122

    Re: debug.writeline or trace.writeline -- no output

    Yes, I know that there are IDE settings. But in this case there all set to their out-of-the-box defaults.

  7. #7

    Re: debug.writeline or trace.writeline -- no output

    I think it has to do with not using the Visual Studio Hosting Process while debugging? I'm not entirely sure, but see if enabling that [if you have it disabled] fixes the problem.

  8. #8

    Thread Starter
    Lively Member
    Join Date
    Jan 2012
    Posts
    122

    Re: debug.writeline or trace.writeline -- no output

    I am running this under Visual Studio Hosting Process

  9. #9

    Thread Starter
    Lively Member
    Join Date
    Jan 2012
    Posts
    122

    Re: debug.writeline or trace.writeline -- no output

    SOLVED it! I had to open the Output window, right click and enable Program Output. Then, the output appeared in the Immediate window.

    I call that counter-intuitive.

  10. #10
    PowerPoster
    Join Date
    Mar 2002
    Location
    UK
    Posts
    4,780

    Re: debug.writeline or trace.writeline -- no output

    I did mention that in my first post, glad you got it sorted.

  11. #11

    Thread Starter
    Lively Member
    Join Date
    Jan 2012
    Posts
    122

    Re: debug.writeline or trace.writeline -- no output

    Yes, I got it sorted, but the solution is mystifying. To summarize, if you want to see the results from debug.writeline or trace.writeline calls when running under the debugger, one must enable the "program output" (not "debug output") in the output window. My expectation would be that debug output would always show when running under the debugger without doing anything special.

  12. #12
    PowerPoster
    Join Date
    Mar 2002
    Location
    UK
    Posts
    4,780

    Re: debug.writeline or trace.writeline -- no output

    They are on by default, at some point in time you likely have turned it off. You can reset the IDE to defaults by a command line I believe, possibly through the IDE somewhere but I have never looked for it.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width