zoukankan      html  css  js  c++  java
  • 让VS2019支持.NET Core WinForms和WPF设计器的临时办法(比微软给出的办法更方便)

    参考以下代码片段,给项目添加NET Framework目标框架,切换到NET472运行时重新生成项目,然后打开设计器界面。
    如果遇到设计器报错,尝试以NET472运行时为目标重新生成项目,并重新打开VS。

    netcore3-winform-designer
    netcore3-wpf-designer

    Design in .NET Framework target, publish in .NET Core 3.

    WinForm

    <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

    <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>
    

    本文首发首发Github WinForms Designer Support

  • 相关阅读:
    Linux组件封装(三) Thread的封装
    Linux组件封装(二) 条件变量Condition的封装
    Linux组件封装(一) 互斥锁MutexLock
    迭代器适配器(二) general inserter的简单实现
    迭代适配器(一) back_insert和front_insert的简单实现
    priority_queue的简单实现
    svm简易例子——matlab版本
    讲座 on the connection between vision and language
    svm相关理解
    为什么深度学习有效?(why deep learning works)
  • 原文地址:https://www.cnblogs.com/zonciu/p/10745152.html
Copyright © 2011-2022 走看看