question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

WinForms Designer Support

See original GitHub issue

In Visual Studio 2019 Preview 1, there is no project template for generating .NET Core 3 WinForms projects. If I instead run on the command line:

dotnet new winforms -o winforms_core_test

a project is created successfully. I can then open the generated .csproj file in VS2019. But the WinForms designer doesn’t seem to be available. Typically the right-click context menu shows “view designer”, but it is missing, and shift+f7 after opening the code doesn’t work either:

missing designer

On a standard WinForms project, the Designer.cs file is typically shown as a child of the form source code, and the designer is available on the context menu:

what it should look like

Is there any way to use the designer with .NET Core 3, or is it planned in the future?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:15
  • Comments:54 (34 by maintainers)

github_iconTop GitHub Comments

14reactions
Zonciucommented, Apr 19, 2019

Before VS2019 supports .Net Core WinForms & WPF Designer, we still be able to use this trick. If Designer reports crash exception, just rebuild your project, or rebuild your project and then restart VS2019.

============================================================

I found an easy way to make VS2019 support net core 3 WinForm & WPF: 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>
12reactions
RussKiecommented, Jul 30, 2019

A preview of the designer will be released as part of .NET 3.0 release in September 2019.

Read more comments on GitHub >

github_iconTop Results From Across the Web

State of the Windows Forms Designer for .NET Applications
As you may be aware, a new WinForms designer was needed to support .NET Core 3.1 applications, and later .NET 5+ applications.
Read more >
How to add designer support to Winforms extension control?
I'm creating a Windows form application using C# and the .Net 5.0 framework, and would like to create an extension class of the...
Read more >
Support WinForms Designer for .NET Core : RIDER-58357
I'm very disappointed, that Rider does not support Winforms designer for .NET core. 9. Denis Vladimirovich commented 24 Nov 2021 19:40.
Read more >
Why doesn't VS 2022 show my WinForms UI at design time?
Basically, it's because Visual Studio is now a 64-bit app and the WinForms designer runs in the same process as VS. In other...
Read more >
In VS 2022, WinForms Designer Still Chasing Parity with . ...
Databinding Support: WinForms in Visual Studio 2022 brings a streamlined approach for managing Data Sources in the OOP designer with the ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found