Quantcast
Channel: C#タグが付けられた新着記事 - Qiita
Viewing all articles
Browse latest Browse all 9749

ConsoleアプリケーションでSystem.Windows.Formsを使う

$
0
0
dotNET Core のConsoleアプリケーションでSystem.Windows.Formsを使いたい はじめに Visual Studio Code で コンソールプログラムを作成するときですが フォームアプリケーションを操作したいなと思ったときにusingが足りなくて困ったのでそのTipsです。 動作環境 Windows10 Pro 21H2 Visual Studio Code dotNET Core 6.0.101 結論 .csproj ファイルに追記するだけでOKです。 方法 これがデフォルトの.csproj ファイルの中身です。 <Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <OutputType>Exe</OutputType> <TargetFramework>net6.0</TargetFramework> <ImplicitUsings>enable</ImplicitUsings> <Nullable>enable</Nullable> </PropertyGroup> </Project> 上記の記載を以下のように変更します。 <Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <OutputType>Exe</OutputType> <TargetFramework>net6.0-windows</TargetFramework> <UseWindowsForms>true</UseWindowsForms> <ImplicitUsings>enable</ImplicitUsings> <Nullable>enable</Nullable> </PropertyGroup> </Project> これでConsoleアプリケーション から Sysmtem.Windows.Forms を利用できます。 おわり

Viewing all articles
Browse latest Browse all 9749

Trending Articles