需要帮助将 winform 迁移到 net 5 [英] need help migrating winform to net 5

查看:31
本文介绍了需要帮助将 winform 迁移到 net 5的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将一个 winform 应用程序从 net core 3.1 移植到 net 5 并收到以下错误.

I'm porting a winform app from net core 3.1 to net 5 and getting the following error.

严重性代码描述项目文件行抑制状态错误 NETSDK1136 目标平台必须设置为 Windows(通常通过在 TargetFramework 属性中包含-windows")使用时Windows 窗体或 WPF,或引用执行此操作的项目或包所以.PublicOutput.core C:ProgramFilesdotnetsdk5.0.100SdksMicrosoft.NET.Sdk argetsMicrosoft.NET.Sdk.DefaultItems.targets 369

Severity Code Description Project File Line Suppression State Error NETSDK1136 The target platform must be set to Windows (usually by including '-windows' in the TargetFramework property) when using Windows Forms or WPF, or referencing projects or packages that do so. PublicOutput.core C:Program Filesdotnetsdk5.0.100SdksMicrosoft.NET.Sdk argetsMicrosoft.NET.Sdk.DefaultItems.targets 369

这是所指的 Microsofts.net.sdk.DefaultItems.targets 部分.

This is the section of Microsofts.net.sdk.DefaultItems.targets that this is referring to.

  <Target Name="_CheckForInvalidWindowsDesktopTargetingConfiguration"
        BeforeTargets="_CheckForInvalidConfigurationAndPlatform"
        Condition="'$(TargetFrameworkIdentifier)' == '.NETCoreApp' and $([MSBuild]::VersionGreaterThanOrEquals($(_TargetFrameworkVersionWithoutV), '5.0')) and ('$(UseWindowsForms)' == 'true' or '$(UseWPF)' == 'true')">
    <NETSdkError Condition="'$(TargetPlatformIdentifier)' != 'Windows'"
                 ResourceName="WindowsDesktopTargetPlatformMustBeWindows" >

我不明白错误,错误发送给我的链接没有帮助

I don't understand the error and the link where the error sends me is not helpful

https://docs.microsoft.com/en-us/visualstudio/?f1url=%3FappId%3DDev16IDEF1%26l%3DEN-US%26k%3Dk(NETSDK1136)%26rd%3Dtrue&view=vs-2019

我的目标框架设置如下:

I've got my target framework set to the following:

    <TargetFramework>net5.0</TargetFramework>
<UseWindowsForms>true</UseWindowsForms>

任何帮助将不胜感激

推荐答案

错误很明显:

目标平台必须设置为Windows(通常通过包括TargetFramework 属性中的-windows")在使用 Windows 时表单或 WPF,

The target platform must be set to Windows (usually by including '-windows' in the TargetFramework property) when using Windows Forms or WPF,

因此将 net5.0 更改为 net5.0-windows 作为 写在文档中

这篇关于需要帮助将 winform 迁移到 net 5的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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