.NET 5 / Windows Forms에서 Console창이 뜨지 않는 경우

.NET Framework에서 Windows Forms으로 개발하다 보면 빠르게 결과를 출력해보고 싶어 간혹 출력 형식을 콘솔 애플리케이션으로 바꾼 후 확인하곤 합니다.

그런데 .NET 5에서 동일하게 출력 형식을 콘솔 애플리케이션으로 바꾼 후 실행해보았는데 콘솔이 안뜨는 군요. 이럴때 프로젝트 설정에 <DisableWinExeOutputInference>true</DisableWinExeOutputInference>를 추가하면 됩니다.

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net5.0-windows</TargetFramework>
    <UseWindowsForms>true</UseWindowsForms>
    <DisableWinExeOutputInference>true</DisableWinExeOutputInference>
  </PropertyGroup>
3개의 좋아요

아니면 바꾸지 마시고 디버깅 용도로 콘솔을 함께 띄워 놓는 것도 좋을 듯합니다. ^^

.NET Framework: 851. WinForm/WPF에서 Console 창을 띄워 출력하는 방법 (sysnet.pe.kr)

2개의 좋아요

바로 적용했습니다 ^^

image

.NET Framework: 1031. WinForm/WPF에서 Console 창을 띄워 출력하는 방법 (2) - Output 디버깅 출력을 AllocConsole로 우회 (sysnet.pe.kr)