可以在 net8 项目中引用 Windows 窗体吗?

问题描述 投票:0回答:1

在这里谷歌搜索了一段时间,完全没有方向......

我们已经有了一个很大的解决方案,我们正在将其迁移到 net8(从 net 481 ... bleh)。 大部分内容已排序,但由于某种原因,似乎无法弄清楚是否可以引用 net8 中的 win 表单程序集。

谷歌搜索表明微软甚至在 net8 中为 win 表单添加了新功能。所以我想这应该是可能的。

努力让它发挥作用:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>net8.0-windows</TargetFramework>
    <RootNamespace>IAI.Common.Utilities.Utils</RootNamespace>
    <AssemblyName>IAI.Common.Utilities.Utils</AssemblyName>
  </PropertyGroup>
  <ItemGroup>
    <ProjectReference Include="..\IAI.Common.Utilities.Logging\IAI.Common.Utilities.Logging.csproj" />
  </ItemGroup>
  <ItemGroup>
    <PackageReference Include="DotNetZip" Version="1.16.0" />
    <PackageReference Include="Extensions.Serialization" Version="3.3.0" />
    <PackageReference Include="log4net" Version="2.0.15" />
    <PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.3"/> <!-- Doesn't work -->
    <PackageReference Include="System.Management.Automation" Version="7.4.1" />
    <PackageReference Include="TestableIO.System.IO.Abstractions" Version="20.0.15" />
  </ItemGroup>
  <ItemGroup>
    <Reference Include="WindowsBase" /> <!-- Doesn't work -->
    <Reference Include="System.Windows.Forms" /> <!-- Doesn't work -->
  </ItemGroup>
  <ItemGroup>
    <Compile Update="Timer\TimerAdaper.cs" />
  </ItemGroup>
</Project>

所有尝试都不允许我包含命名空间 System.Windows.Forms。

这个建议应该是可以的吧?

https://learn.microsoft.com/en-us/dotnet/api/system.windows.forms.messagebox.show?view=windowsdesktop-8.0

c# winforms .net-8.0
1个回答
0
投票

不好笑......

  <PropertyGroup>
    <TargetFramework>net8.0-windows</TargetFramework>
    <UseWindowsForms>true</UseWindowsForms> <----- .....

呃..

© www.soinside.com 2019 - 2024. All rights reserved.