4

I have a problem where a Console app window is not showing during debugging when there is also a .NET Core web app inside the same solution. The console app code runs fine, just no black console window.

Visual Studio: Version 15.5.6 Microsoft .NET Framework: Version 4.7.02556

Console App: Target Framework: .NET Framework 4.6.1 Web App: Target Framework: .NET Core 2.0

If I create a separate .sln and add the .NET Framework console app to it, the window shows during debugging. Both the Core 2 web and the .NET Framework console share a .NET Standard library.

Dranyar
  • 580
  • 1
  • 10
  • 16

5 Answers5

8

I was suffering from the same problem on an inherited legacy application.

The issue here was that although the application had the structure of a Console App, it was actually configured to run as a Windows App (with no code to show forms or anything).

enter image description here

To fix, I just changed Windows App to Console App in the project's Properties page.

enter image description here

Matt Shepherd
  • 782
  • 10
  • 21
  • 1
    I seem to be getting this with the latest VS 2019 v16.8.2 update. Toggling it back to "console application" doesn't "stick" - it keeps reverting back to "Windows application". – Chris Smith Nov 25 '20 at 23:46
  • 1
    I'm having all sorts or problems since "upgrading" to v16.8.2. Sorry I can't be more help, but at least you know you're not alone! – Matt Shepherd Dec 03 '20 at 03:22
  • I followed comments from [here](https://learn.microsoft.com/answers/answers/169559/view.html): checkout .proj file from source control (if you have it) > open it in notepad > remove " true" – Chris Smith Dec 04 '20 at 05:54
  • Or true, and live with the build target warning "NETSDK1106 Microsoft.NET.Sdk.WindowsDesktop requires 'UseWpf' or 'UseWindowsForms' to be set to 'true'" – Rob Jan 07 '21 at 16:05
6

At the top of your Visual Studio IDE enter image description here

change the enter image description here

and in the drop down , select your Project name instead i.e) enter image description here

AngelaG
  • 609
  • 12
  • 14
3

This is a genuine issue. I'm having the the exact same problem on all my development machines.

Visual Studio: Version 15.6.4 Microsoft .NET Framework: Version 4.7.02556

Console App: Target Framework: .NET Framework 4.6.1 Web App: Target Framework: .NET Core 2.0

I've tried to unload/reload projects, changed target framework back and forth and a few other things. Nothing helps. Running my project from within VS2017 works the first 5-10 times when starting VS2017 and loading up my project. Then all of a sudden the console windows just stops showing when running/debugging from within VS2017. But the app is running in the background for sure.

UPDATE:

As earlier stated I did try to change the target framework of my problematic project back and forth. Instead of changing back and forth I tried to just change the target framework to 4.7.1 and keep it there. That resolved the issue.

Jabak
  • 81
  • 1
  • 2
  • Still an issue with aps.net core 3.1 wherein you cannot select 4.6.1 as a target framework. – T3.0 Sep 23 '20 at 19:39
1

I can't comment for clarification(don't have the reputation yet) did you set your console project as the start up project or the web project? You can switch between the two if you're trying to debug something on the console or on your site.

You can also unload/load your web project to switch between them. Whatever is easiest for you.

enter image description here

Right click on your project and click on 'Set as StartUp Project'.

If this option isn't available unload your web project by right clicking on that project and selecting 'Unload Project'. Try changing the startup project again.

ismael.
  • 418
  • 2
  • 7
  • Yes, I did that and no console shows. It should not even be necessary. – Dranyar Mar 09 '18 at 14:40
  • @Dranyar Try unloading your web project, setting your console as the startup project. Run your project. – ismael. Mar 09 '18 at 14:42
  • @Dranyar You can unload your web project by right clicking on the project and clicking unload project. You can easily toggle between that and load. – ismael. Mar 09 '18 at 14:44
  • I am using using two separate solutions/visual studio instances. I curious as to the reason it isn't working in the same solution. – Dranyar Mar 10 '18 at 23:48
  • @Dranyar have your checked out this answer https://stackoverflow.com/questions/3850019/running-two-projects-at-once-in-visual-studio – ismael. Mar 12 '18 at 15:15
  • The multiple startup project configuration is just a convenience feature so that you don't have to click on each project and do "Debug->Start" . – Dranyar Mar 12 '18 at 15:29
  • @Dranyar I think it's because both projects need to have a static void Main... so it knows where to start. When you select the start up option in visual studio it basically starts there at the beginning and works it's way down. – ismael. Mar 12 '18 at 15:33
0

I was facing the same issue, Changed my Framework from 4.7 to 4.5 and then again to 4.7 and it started working. Bit of weird but it worked for me.

Zaveed Abbasi
  • 446
  • 1
  • 12
  • 34