在 .Net Core 中添加 System.Windows.forms 的引用 [英] Add reference of System.Windows.forms in .Net Core

查看:80
本文介绍了在 .Net Core 中添加 System.Windows.forms 的引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想写入我的 .resx 文件.我使用了 ResXResourceWriter,它在 Windows 形式下运行良好,但在 .Net Core 应用程序中不可用.它需要 system.Windows.Forms 但 .net core 不引用它.

I want to write in my .resx file. I have used ResXResourceWriter which works fine in Windows form but doesn't available in .Net Core application. It needs system.Windows.Forms but .net core don't reference to it.

ResXResourceWriter resx = new ResXResourceWriter(hostingEnvironment.WebRootPath + "LocalizationLabelResource.EN.resx")

ResXResourceWriter resx = new ResXResourceWriter(hostingEnvironment.WebRootPath + "LocalizationLabelResource.EN.resx")

推荐答案

如果您已经安装了 .net Core 3.0(或更高版本)并且想要添加对现有项目 (.csproj) 的引用.

If you already have .net Core 3.0 (or more) installed and want to add a reference to an existing project (.csproj).

您只能添加以下标签:

true 进入以下部分:

我认为它是新的:菜单编辑项目文件"在 Visual Studio 的项目上下文菜单中.

像这样(添加到 WPF 项目中):

Like so (added into a WPF project):

<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">

  <PropertyGroup>
    <TargetFramework>netcoreapp3.1</TargetFramework>
    <UseWPF>true</UseWPF>
    <UseWindowsForms>true</UseWindowsForms>
  </PropertyGroup>

  <ItemGroup>
    <ProjectReference Include="..GeneralCoreGeneralCore.csproj" />   </ItemGroup>

</Project>

这篇关于在 .Net Core 中添加 System.Windows.forms 的引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆