3

I've got a strange one here that I can't seem to figure out. It just started last week. When I debug a console app in VS 2019 it does not launch the console window. I can set a breakpoint inside Main() and it will break. But no console.

I even created a brand new Hello World project and that does not work.

  • VS 2019 Build 16.5.4 (updated today from 16.5.1 but that did not help)
  • Windows 10 x64 Build 18363
  • .NET Framework 4.7.2 (for the test app below but I have seen it in all versions I've tried).

Even this does not work:

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApp1 { class Program { static void Main(string[] args) { Console.WriteLine ("Hello World"); Console.ReadLine(); } } } 
5
  • One more thing I just tried ... a .NET Core Console App. This works. But not Framework ones. Commented Apr 22, 2020 at 3:31
  • I have tested it, it works for me. I need to mention that the console will appear after the Main method is ended. Therefore. I suggest that you can set the break point after the console.readline() to check if it works for you. Commented Apr 23, 2020 at 1:42
  • Yeah this is definitely environmental. This worked forever ... for some reason it stopped. If I run the above with no breakpoints same result. The project is running ... can see activity in diagnostics, but no console. Commented Apr 23, 2020 at 3:29
  • 1
    Based on my search, I find some ways may solve it. First way, you can change Platform Target to x64. Second way, The following is a temporary solution. 1. Kill the remaining {project} .exe process. 2. Exit visual studio 2017. 3. Kill all cmd.exe and conhost.exe processes. 4. Run visual studio 2017 again. Commented Apr 24, 2020 at 2:12
  • Just throwing this out there... had the same problem myself... the solution was to debug the app once with VS 2017 and then when I switched back to VS2019 it was just working. Commented Nov 17, 2020 at 17:19

2 Answers 2

3

As Jack J Jun mentioned, setting target to x64 in VS 2019 helped me. Solution was designed in VS 2017 and then studio was upgraded and yes, console application stopped showing its console.

Sign up to request clarification or add additional context in comments.

1 Comment

Hi Mike, thank you for contributing to stack overflow! I wonder if some exception is being swallowed by VS and handled silently - when you change your exception settings to stop on all exceptions, does it break, or does it still just continue silently? I wonder if the Event viewer on Windows will report some errors :?
1

I had the same thing happen right after I upgraded to VS 2019. Culprit was this line in my csproj file: <UseWindowsForms>true</UseWindowsForms>. Not sure how this line got in there...I didn't consciously add it. Either the upgrade added it or it was added when I unknowingly clicked on something and the previous version of VS just ignored it. Anyway, I deleted the line from the csproj file and the console window came back.

1 Comment

Sorry, the line is "UseWindowsForm" (enclosed in <>) set to true. The comment editor is removing it I think because it thinks it's a tag.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.