?
Solved

System.Diagnostics.Debug.WriteLine

Posted on 2006-05-20
23
Medium Priority
?
1,561 Views
Last Modified: 2008-01-09
System.Diagnostics.Debug.WriteLine(sqlText4 + "\n");

Can someone please tell me where the above output goes. Which window? I am in debug configuration and for the life of me cannot find it anywhere.
0
Comment
Question by:claghorn
  • 9
  • 7
  • 4
  • +1
21 Comments
 
LVL 11

Expert Comment

by:anyoneis
ID: 16726503
Output. CTL-Alt-O with std c# setup or View, Output.

DAvid
0
 

Author Comment

by:claghorn
ID: 16726560
maybe so but why does my editor skip over this line? I have my project set to debug.
0
 
LVL 11

Expert Comment

by:vo1d
ID: 16727872
is it a console application?
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:claghorn
ID: 16729320
yes, it is a cosole application, but can't I write to the immediate window at least?
worst case I'll have to write to file maybe. I'm just trying to generate sql that I can run in another window.
0
 
LVL 11

Expert Comment

by:anyoneis
ID: 16729452
If it is a console application, why not write it to the console using Writeline? Something like:

using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleOutput
{
    class Program
    {
        static void Main(string[] args)
        {

            Console.WriteLine("Copy Me!");
            Console.WriteLine("Copy Me!");
            System.Diagnostics.Debug.WriteLine("Copy Me!");
            System.Diagnostics.Debug.WriteLine("Copy Me!");

            Console.ReadKey();
        }
    }
}


To copy the output form the DOS window, right click on the title bar of the DOS window and select Edit, Mark. Then use the mouse to select the text you want to put on the clipboard and right click again. That will copy the highlight region to the clipboard.

Alternatively, just use Visual studio, View, Output. There, after the program has run, will be whatever you put using  System.Diagnostics.Debug.WriteLine.

David
0
 
LVL 11

Expert Comment

by:vo1d
ID: 16729456
so because you are using a console app, you will have to use Console.WiteLine to get output.
0
 

Author Comment

by:claghorn
ID: 16729657
The console window is useless to me. I cannot copy all 455 lines that I need. There is a ceiling that I cannot break through. The console window is not scrollable and is too narrow. It breaks each line into two which won't run in the other window I going to run the statements in. The View - Output is useless too. It shows non sql statements that the compiler generates.
0
 
LVL 11

Expert Comment

by:vo1d
ID: 16729683
could you set a breakpoint to that line?
or is it marked as inactive?
0
 

Author Comment

by:claghorn
ID: 16729754
the line does'nt exist according to the runtime engine. I think I'll have to a file, if it can do that.
0
 
LVL 11

Expert Comment

by:anyoneis
ID: 16729789
Are you doing a release build? The line wouldn't exist if so. Right-click on the solution in the solution explorer, then select conjfiguration manager. Ensure you are doing a debug build.

David
0
 

Author Comment

by:claghorn
ID: 16729806
yep, its in debug configuration.
0
 
LVL 11

Expert Comment

by:vo1d
ID: 16729818
which framework version do you use?
0
 

Author Comment

by:claghorn
ID: 16729859
vs 2005
0
 
LVL 11

Expert Comment

by:vo1d
ID: 16729865
try to output a static text with a breakpoint like this:
System.Diagnostics.Debug.WriteLine("ok");

does your breakpoint not work too?
0
 

Author Comment

by:claghorn
ID: 16729891
it skips over it., but even if it did not I'd have to continue 455 times, the amount of sql lines i'm generating. don't want to do that.
0
 
LVL 11

Expert Comment

by:vo1d
ID: 16729910
then use the StreamWriter class to write to a textfile.
0
 
LVL 11

Expert Comment

by:anyoneis
ID: 16729936
When I compile and run the program I sent you, and look in the Output Window, I see:

'ConsoleOutput.vshost.exe' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_32\mscorlib\2.0.0.0__b77a5c561934e089\mscorlib.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'ConsoleOutput.vshost.exe' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\Microsoft.VisualStudio.HostingProcess.Utilities\8.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.HostingProcess.Utilities.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'ConsoleOutput.vshost.exe' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\System.Windows.Forms\2.0.0.0__b77a5c561934e089\System.Windows.Forms.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'ConsoleOutput.vshost.exe' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\System\2.0.0.0__b77a5c561934e089\System.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'ConsoleOutput.vshost.exe' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\System.Drawing\2.0.0.0__b03f5f7f11d50a3a\System.Drawing.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'ConsoleOutput.vshost.exe' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\Microsoft.VisualStudio.HostingProcess.Utilities.Sync\8.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.HostingProcess.Utilities.Sync.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'ConsoleOutput.vshost.exe' (Managed): Loaded 'C:\Documents and Settings\drogers\My Documents\Visual Studio 2005\Projects\ConsoleOutput\ConsoleOutput\bin\Debug\ConsoleOutput.vshost.exe', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'ConsoleOutput.vshost.exe' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_32\System.Data\2.0.0.0__b77a5c561934e089\System.Data.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'ConsoleOutput.vshost.exe' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\System.Xml\2.0.0.0__b77a5c561934e089\System.Xml.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
The thread 0x96c has exited with code 0 (0x0).
The thread 0x1e48 has exited with code 0 (0x0).
'ConsoleOutput.vshost.exe' (Managed): Loaded 'C:\Documents and Settings\drogers\My Documents\Visual Studio 2005\Projects\ConsoleOutput\ConsoleOutput\bin\Debug\ConsoleOutput.exe', Symbols loaded.
'ConsoleOutput.vshost.exe' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\System.Configuration\2.0.0.0__b03f5f7f11d50a3a\System.Configuration.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
Copy Me!  <<<-------
Copy Me!  <<<-------
The thread '<No Name>' (0x3d8) has exited with code 0 (0x0).
The thread 0x1d74 has exited with code 0 (0x0).
The program '[2836] ConsoleOutput.vshost.exe: Managed' has exited with code 0 (0x0).


Which, yes, has a bunch of compiler stuff, but it also has my output!!

David
0
 

Author Comment

by:claghorn
ID: 16729956
yes, isee but that would not help me at all. I have to write to a file. Thanks Anyways.
0
 
LVL 11

Expert Comment

by:vo1d
ID: 16730068
maybe it is a bug if you use the vshost.exe process to run your application in your ide.
disable that option and try again.
0
 

Author Comment

by:claghorn
ID: 16772146
My solution was to write output to file. Here is the code for this. Hope this helps someone?
public static System.String tempFile = "C:\\logfile1";
StreamWriter streamWriter = null;
try
{
    // open for append
    streamWriter = new StreamWriter(tempFile, true);
    // append some text
    streamWriter.WriteLine(sqlText);
}

if (streamWriter != null)
             streamWriter.Close();

This thread is closed. Thanks
0
 

Accepted Solution

by:
GranMod earned 0 total points
ID: 17011682
PAQed with points refunded (20)

GranMod
Community Support Moderator
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses
Course of the Month16 days, 19 hours left to enroll

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question