Skip to content

WinForms Designer Support #147

Closed
Closed

Description

@bobasaurus

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?

Activity

  1. dotMorten commented on Dec 4, 2018

    @dotMorten
    Contributor

    That limitation is already documented on the landing page : https://github.com/dotnet/winforms/blob/master/README.md

    Note: The Windows Forms visual designer is not yet available and will be part of a Visual Studio 2019 update.

  2. bobasaurus commented on Dec 4, 2018

    @bobasaurus
    Author

    Ah, I must have missed that. Thanks, looking forward to future support.

  3. zsd4yr commented on Dec 4, 2018

    @zsd4yr
    Contributor

    Going to keep this issue open so that people can track anything on-going here

  4. changed the title [-]VS2019 .Net Core 3 WinForms Designer Support Missing?[/-] [+]WinForms Designer Support[/+] on Dec 4, 2018
  5. added
    enhancement
    on Dec 4, 2018
  6. Tanya-Solyanik commented on Dec 4, 2018

    @Tanya-Solyanik
    Contributor

    Workaround to use the designer is to create two apps:

    • .NET Framework app for designing the WinForms app
    • .NET Core app to run the WinForms application
      Both the applications will reference same files.

    Steps:

    1. Using developer command prompt, create a .NET Core WinForms app. This app will be used to run the WinForms application. Steps:
      Open developer command prompt and run following command:
      "C:\Program Files\dotnet\dotnet.exe" new winforms -o <>

    2. From Visual Studio, create a new Windows Forms App (.NET Framework) project. This project will be used to design the WinForms. Steps:
      a. Go to File -> New -> Project
      b. Select Visual C# -> Windows Forms App (.NET Framework)
      c. From solution explorer, select Form1.cs and all the sub files under this node -> right click -> Delete
      d. Select project -> right click -> Add Existing Item
      e. Browse to the Form1.cs file in the .NET Core WinForms app folder which would have got created in Step 1
      f. In the Add Existing Item dialog, select Form1.cs file and change Add to 'Add As Link' option
      image

       g. Build the project. There might be a build error to add a using statement for the namespace having Form1. Add that and build the project
       h. Run the application and Form1 should show up
       i. To display Form1 in designer, right click on Form1.cs -> Open with -> select CSharp Form Editor (Default) -> Ok
      

    image
    Now the Net Framework app can be used to design the WinForms and .NET Core app can be used to run the application.

    Workaround provided by @Shyam-Gupta

  7. KlausLoeffelmann commented on Dec 5, 2018

    @KlausLoeffelmann
    Member

    I am not sure if this will work properly, since the resulting files are not nested/missing the .designer.cs file in the classic framework project. The designer would pick this up all right, but would on CodeDom serialization create InitializeComponent in the main form class, thus projects ending up with two InitializeComponent methods and wouldn't really compile?

    (Correct me, if I am missing something here!).

    I think what's need to be done here is adding links to all three files, and then nest them in the Classic Framework Project in addition, so changes from the Visual Designer would actually go into the form.designer.cs.

  8. added this to the milestone on Dec 6, 2018
  9. jnm2 commented on Dec 6, 2018

    @jnm2
    Contributor
  10. zsd4yr commented on Dec 6, 2018

    @zsd4yr
    Contributor

    @jnm2 this issue tracks only Winforms while dotnet/project-system#2963 is tracking progress for Winforms and WPF. I don’t think either has to be duped, but feel free to relate the two :)

  11. modified the milestones: , Future on Dec 6, 2018
  12. maikebing commented on Dec 7, 2018

    @maikebing
    Contributor

    Failed to load file or assembly "System.ComponentModel.TypeConverter, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a "Or one of its dependencies. The system could not find the specified file.

  13. wjk commented on Jan 26, 2019

    @wjk
    Contributor

    I've figured out how to workaround the assembly-load failure identified by @maikebing. What you need to do is to multitarget your .NET Core (SDK-style csproj) project to multitarget .NET Framework as well as .NET Core, ensuring that the .NET Framework TFM is first in the list. This will cause VS to attempt to resolve the designer types using .NET Framework before it tries (and fails) to do so using .NET Core.

    Only problem I have identified is, when I try to debug it, it now debugs only the .NET Framework version. I am not certain how to instruct the VS debugger to target the .NET Core version, while not breaking the designer. In the meanwhile, we can run the .NET Core EXE from the command line and do Debug > Attach to Process.

    In short: The Windows Forms designer now works with Visual Studio 2019! 🎉 🎉 🎉

  14. 39 remaining items

  15. fatihyildizhan commented on Sep 23, 2019

    @fatihyildizhan

    <TargetFrameworks>net48;netcoreapp3.0</TargetFrameworks> didn't work for me but <TargetFrameworks>net472;netcoreapp3.0</TargetFrameworks> works fine for both WinForms and WPF with Visual Studio 16.3.0.

  16. RussKie commented on Sep 23, 2019

    @RussKie
    Contributor

    <TargetFrameworks>net48;netcoreapp3.0</TargetFrameworks> didn't work for me

    Do you have .NET 4.8 installed?

  17. merriemcgaw commented on Sep 24, 2019

    @merriemcgaw
    Contributor

    And do you have the targeting pack installed for .NET 4.8?

  18. KaneLeung commented on Sep 25, 2019

    @KaneLeung

    netcore 3.0 designer preview
    you can use this vsix
    TIM截图20190925103338

  19. RussKie commented on Sep 25, 2019

    @RussKie
    Contributor

    I'm going to close this since we have released a Windows Forms Designer for .NET Core; more information here - https://github.com/dotnet/winforms/tree/master/Documentation/designer-releases.
    The current Designer is still in a preview state and supports the basic set of control. The team is working around the clock to bridge the remaining gap.

  20. removed this from the Future milestone on Sep 25, 2019
  21. added
    area-VSDesigner
    and removed
    enhancement
    on Sep 25, 2019
  22. added this to the 3.0-GA milestone on Sep 25, 2019
  23. paul1956 commented on Oct 5, 2019

    @paul1956
    Contributor

    As far as I can tell these instructions are still needed for VB since the preview does not work.

  24. dotMorten commented on Oct 20, 2019

    @dotMorten
    Contributor

    @Karaulov
    You saw this note right?

    The current Designer is still in a preview state

    Also did you submit feedback in Visual Studio when you hit this issue? That's probably going to be more constructive and give the team something actionable.

  25. fatihyildizhan commented on Oct 20, 2019

    @fatihyildizhan

    @Karaulov Which version are you using? Did you upgrade to the latest version?

  26. unpinned this issue on Nov 11, 2019
  27. ghost locked as resolved and limited conversation to collaborators on Feb 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-VSDesigner

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions