我创建了 .NET Core 类库并尝试针对 net40 框架构建它。我想使用 System.Windows.Forms 程序集中的 Clipboard 类。我怎样才能做到这一点?
我的project.json 文件:
{
"version": "1.0.0-*",
"dependencies": {
"NETStandard.Library": "1.6.0"
},
"frameworks": {
"netstandard1.6": {
"imports": "dnxcore50",
"buildOptions": {
"define": [
"NETCORE"
]
},
"dependencies": {
"System.Threading": "4.0.11",
"System.Threading.Thread": "4.0.0",
"System.Threading.Tasks": "4.0.11"
}
},
"net40": {
"buildOptions": {
"define": [
"NET40"
]
},
"dependencies": {
// dependency should be here but there is no such dll
}
}
}
}
我所有的 net40 特定代码都在 NET40 定义下。有什么想法吗?
对于 VS2019 .NET Core 3.1:
- 右键单击项目并选择卸载项目
- 右键单击该项目并选择“编辑 foobar.csproj”
- 在 .NET Core 3.1 中使用 WPF 和 Winforms 的示例:我在其中添加了 UseWPF 和 UseWindowsForms 标记。我也改变了
Microsoft.NET.Sdk
to Microsoft.NET.Sdk.WindowsDesktop
也能够使用wpf。
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
<PropertyGroup Label="Globals">
<SccProjectName>SAK</SccProjectName>
<SccProvider>SAK</SccProvider>
<SccAuxPath>SAK</SccAuxPath>
<SccLocalPath>SAK</SccLocalPath>
</PropertyGroup>
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<UseWPF>true</UseWPF>
<UseWindowsForms>true</UseWindowsForms>
</PropertyGroup>
...
- 保存并再次右键单击该项目并选择重新加载项目
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)