.net core 3.0 Preview 6,vs2019 16.1.4 暂时还不支持Winform designer
解决方案:
将Form1修改为其他名字
WinForm 编辑项目文件 加入 TargetFrameworks 使其支持net472;
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop"> <PropertyGroup> <OutputType>WinExe</OutputType> <TargetFrameworks>net472;netcoreapp3.0</TargetFrameworks> <UseWindowsForms>true</UseWindowsForms> <LangVersion>7.3</LangVersion> </PropertyGroup> <ItemGroup Condition=" '$(TargetFramework)' == 'net472' "> <Reference Include="System" /> <Reference Include="System.Core" /> <Reference Include="System.Xml.Linq" /> <Reference Include="System.Data.DataSetExtensions" /> <Reference Include="Microsoft.CSharp" /> <Reference Include="System.Data" /> <Reference Include="System.Deployment" /> <Reference Include="System.Drawing" /> <Reference Include="System.Net.Http" /> <Reference Include="System.Windows.Forms" /> <Reference Include="System.Xml" /> </ItemGroup> <ItemGroup Condition=" '$(TargetFramework)' == 'net472' "> <!-- add From files to here to enable designer --> <Compile Update="Form1.cs"> <SubType>Form</SubType> </Compile> </ItemGroup> </Project>
现在已经支持WPF的设计器了 以下参考
WPF
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop"> <PropertyGroup> <OutputType>WinExe</OutputType> <TargetFrameworks>net472;netcoreapp3.0</TargetFrameworks> <UseWPF>true</UseWPF> </PropertyGroup> <ItemGroup Condition=" '$(TargetFramework)' == 'net472' "> <Reference Include="System" /> <Reference Include="System.Data" /> <Reference Include="System.Xml" /> <Reference Include="Microsoft.CSharp" /> <Reference Include="System.Core" /> <Reference Include="System.Xml.Linq" /> <Reference Include="System.Data.DataSetExtensions" /> <Reference Include="System.Net.Http" /> <Reference Include="System.Xaml"> <RequiredTargetFramework>4.0</RequiredTargetFramework> </Reference> <Reference Include="WindowsBase" /> <Reference Include="PresentationCore" /> <Reference Include="PresentationFramework" /> </ItemGroup> <ItemGroup Condition=" '$(TargetFramework)' == 'net472' "> <!-- add files to here to enable designer --> <Compile Update="App.xaml.cs"> <DependentUpon>App.xaml</DependentUpon> <SubType>Code</SubType> </Compile> <Compile Update="MainWindow.xaml.cs"> <DependentUpon>MainWindow.xaml</DependentUpon> <SubType>Code</SubType> </Compile> </ItemGroup> </Project>