Code/WPF

콘솔 프로그램에서 WPF 사용

Segel 2021. 6. 30. 11:51

문제:

    콘솔 프로그램에서 System.Windows.Media.Imaging을 사용할 필요가 생겼음

해결:

    csproj 파일에

    <UseWPF>true</UseWPF>

    <DisableWinExeOutputInference>true</DisableWinExeOutputInference>추가

    TargetFramework에 "-windows" 추가해주어야 함

예시:

<Project Sdk="Microsoft.NET.Sdk">
	<PropertyGroup>
		<OutputType>Exe</OutputType>
		<TargetFramework>net5.0-windows</TargetFramework>
		<UseWPF>true</UseWPF>
		<DisableWinExeOutputInference>true</DisableWinExeOutputInference>
	</PropertyGroup>
</Project>
반응형