[英]Add reference of System.Windows.forms in .Net Core
我想寫入我的 .resx 文件。 我使用了 ResXResourceWriter,它在 Windows 形式下運行良好,但在 .Net Core 應用程序中不可用。 它需要 system.Windows.Forms 但 .net core 不引用它。
ResXResourceWriter resx = new ResXResourceWriter(hostingEnvironment.WebRootPath + "\\Localization\\LabelResource.EN.resx")
如果您已經安裝了 .net Core 3.0(或更高版本)並且想要添加對現有項目 (.csproj) 的引用。
您只能添加以下標簽:
<UseWindowsForms>true</UseWindowsForms>
進入以下部分: <PropertyGroup>
我認為它是新的:Visual Studio 項目上下文菜單中的菜單“編輯項目文件”。
像這樣(添加到 WPF 項目中):
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<UseWPF>true</UseWPF>
<UseWindowsForms>true</UseWindowsForms>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\GeneralCore\GeneralCore.csproj" /> </ItemGroup>
</Project>
您目前需要使用.Net Core 3.0 Preview ,因為 System.Windows.Forms 是 .Net Core 3.0 中的新增功能。 從System.Windows.Forms 存儲庫:
您可以使用 dotnet new 命令創建一個新的 WinForms 應用程序,使用以下命令:
dotnet new winforms -o MyWinFormsApp cd MyWinFormsApp dotnet run
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.