【发布时间】:2019-11-28 16:00:01
【问题描述】:
我的 .NET Core 3 WPF 应用程序需要 2 个程序集 - System.Windows.Forms 和 System.Drawing.Common。
当我尝试从公共共享文件夹 (C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App\3.0.0) 将它们添加为 Visual Studio 2019 中的引用时,我收到一个异常消息框,显示“The引用无效或不受支持”。
我预计框架不匹配会发生这种情况,但这是来自 dotnet core v3 共享文件夹,所以一切都应该对齐。
添加这些我不知道的引用有什么特别的技巧吗?
csproj 文件:
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>netcoreapp3.0</TargetFramework>
<UseWPF>true</UseWPF>
<UseWindowsForms>true</UseWindowsForms>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Common\Common.csproj" />
<ProjectReference Include="..\Core\Core.csproj" />
</ItemGroup>
<ItemGroup>
<None Update="logo.ico">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>
【问题讨论】:
-
您可能忘记在项目文件中添加
<UseWindowsForms>true</UseWindowsForms>devblogs.microsoft.com/dotnet/… -
不.. 我知道了:(
-
然后显示完整的项目文件。
-
@LexLi 已添加
-
那么你现在应该可以使用 WinForms 的东西了,因为引用会自动为你解析,
标签: .net-core