locked
C# -- How to Print Lines in Code to Tell You Where You Are RRS feed

  • Question

  • Hi,

    Does anyone know how to get the Console.WriteLine() and/or the Debug.WriteLine() to work when you are debugging C#? In particular, it is the Console.WriteLine in a dll dependency, not in the main program itself.

    All I ever get is a popup that says "Console.cs not found".

    My program has a console. Why can't I just print the message out to the console that opens when I run the program? Is that not possible?

    Thanks!

    Croix


    g


    • Edited by Croix Friday, October 20, 2017 5:44 PM
    Friday, October 20, 2017 5:18 PM

All replies

  • Hi Croix,

    Thanks for your posting.

    May I ask what kind of project you are developing?

    If it's a Class library we won't be able to write the Console.WriteLine(), and we can do it in Console App instead:

    Please feel free to let me know if I misunderstood it.

     

    Best regards,

    Fletcher


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.


    • Edited by Fletch Zhou Monday, October 23, 2017 9:48 AM
    Monday, October 23, 2017 9:48 AM
  • It is a console app. 

    But it calls a class library. I wanted to put Console.WriteLine in the class library to write things out to the console. The main program can write to the console in debug mode but the dependent class library cannot write anything to the console when it is in debug mode.

    Maybe it isn't supposed to be debugged this way?

    Thank you,

    Croix


    g


    • Edited by Croix Tuesday, October 24, 2017 6:33 PM
    Tuesday, October 24, 2017 4:58 PM
  • Hi Croix,

    I don't think we could make it in that way.

    But usually we could create a Unit test project to test(or call) the class library, and we can output something by using Console.WriteLine() and/or the Debug.WriteLine()  under test method( Unit test project) with no problem. You could also debug the specific test method.

    I hope it helps.

     

    Best regard,

    Fletcher


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.



    • Edited by Fletch Zhou Wednesday, October 25, 2017 2:51 AM
    • Proposed as answer by Fletch Zhou Thursday, October 26, 2017 1:33 AM
    Wednesday, October 25, 2017 2:26 AM