0

I'm new to Visual Studio C# and I've created my first DLL. I'm referencing this DLL within a web application. In my code throughout numerous classes within the DLL and even in the controller classes of my web application, I make use of Console.WriteLine(...) to help with troubleshooting. I fully expected those messages to be output to the console at runtime, but they aren't showing up. For example here is some code from a class that is attempting to access a MySQL database, and before I execute the query, I attempt to write the query string to the console:

MySqlCommand cmd = null;
MySqlDataReader rdr = null;
MySqlCommand cmd2 = null;         
try{
        Console.WriteLine("query: " + query.ToString());
        cmd = new MySqlCommand(query.ToString(), conn);
        rdr = cmd.ExecuteReader(); 
        ...
}

In Visual Studio, during project execution time, I've looked at the Immediate Window, the Output, Locals, Call Stack windows.

Where are my writeline messages?

Devin
  • 7,690
  • 6
  • 39
  • 54
Alan
  • 822
  • 1
  • 16
  • 39
  • If you use System.Diagnostics.Debug.WriteLine(...) instead of Console.WriteLine(), then you can see the results in the Output window of Visual Studio. – Tim Schmelter Sep 01 '14 at 20:52
  • Well, I've replaced my Console.WriteLine with System.Diagnostics.Debug.WriteLine where I had them, but my messages still aren't showing up in the Output window! Is there something I'm missing? I am in Debug mode. – Alan Sep 01 '14 at 21:35
  • What kind of web application is it, ASP.NET? Have a look here: http://stackoverflow.com/questions/13000507/why-does-system-diagnostics-debug-writeline-not-work-in-vs2010-c-sharp – Tim Schmelter Sep 01 '14 at 21:39
  • It's an MVC 3 project. – Alan Sep 01 '14 at 21:41
  • Then this seems to be the best duplicate: http://stackoverflow.com/questions/11668521/how-to-use-console-writeline-in-asp-net-mvc-3 – Tim Schmelter Sep 01 '14 at 21:49
  • I found the problem. From the post: http://stackoverflow.com/questions/13000507/why-does-system-diagnostics-debug-writeline-not-work-in-vs2010-c-sharp – Alan Sep 01 '14 at 21:56
  • That was the link from my second to last comment. Glad to hear that it works – Tim Schmelter Sep 01 '14 at 22:01

0 Answers0