1

Often while writing code (graphical application WPF), it becomes necessary to check, for example, the value of an object and display it on the console. Please note that we are talking about the mode without debugging (CTRL + F5). In debug mode, there are many tools for this, including Debug.WriteLine () or Trace.WriteLine (). But debugging is not required every time, more often, during the writing process, it is necessary to run the application without debugging and just check something and display it in the console.

Using .NET Framework 4.8, I was able to select a "console application" (Properties - Application - Console application) and enjoy the output of anything to the console using the good old Concole.WriteLine. However, I switched to .NET 5 and to my surprise I found that I could not select the "console application" and display the information I was interested in. Also, messages are not displayed in VS2019 output window in non-debug mode (Debug constant is defined).

Yes, I know that all these possibilities are there in debug mode (F5), but, again, I don't always want to run it to check the state of an object. What are the ways to display technical information on the screen in non-debugging mode (CTRL + F5) when using .NET 5 (to the Output window or to the console)? Are there possible extensions for this purpose? Thank you.

3
  • Debugging mode is for debugging, non-debugging mode is not meant for debugging. So why wouldn't you use debugging mode? What is the problem you are having with that? Commented Jan 24, 2021 at 7:00
  • which version of VS2019 are you using? Commented Jan 24, 2021 at 7:02
  • VS2019 version is 16.8.4. I don't always need information displayed in debug mode. For example, when I am sum two values, like byte i = 2; byte j = 3; byte x = i + j; I just need to check what the number is x. Yes, I can use MessageBox.Show() for it, but what if there are a lot of stacks. Commented Jan 24, 2021 at 7:11

1 Answer 1

1

After setting Output type to "Console Application", you also need to add this to project(.csproj).

<DisableWinExeOutputInference>true</DisableWinExeOutputInference>

For more details, refer to OutputType set to WinExe for WPF and WinForms apps.

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.