Skip to content

Designer removes needed code #5915

Open

Description

@MisinformedDNA
  • .NET Core Version:
    TargetFramework: net5.0-windows
    SDKs: 6.0.100-rc.1.21463.6, 5.0.401

  • Have you experienced this same bug with .NET Framework?: Haven't tried

Problem description:

When I try to edit a control from the designer. The designer will remove needed parts of the code from *.Designer.cs which results in run-time errors.

Expected behavior:

Designer doesn't remove necessary code.

Minimal repro:

  1. Open control in designer
  2. Edit a property

Designer removed the assignment of two fields resulting in NullReferenceExceptions at run-time.

winforms-designer-repro.mp4

Code

Code after designer changes New after changes

NOTE: I inherited this code and have never used the designer on this control before, so maybe something the designer.cs or resx files are invalid in some way?

dotnet --info

❯ dotnet --info
.NET SDK (reflecting any global.json):
Version:
Commit: e627d556a1

Runtime Environment:
OS Name: Windows
OS Version: 10.0.18363
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\6.0.100-rc.1.21463.6\

Host (useful for support):
Version: 6.0.0-rc.1.21451.13
Commit: d7619cd4b1

.NET SDKs installed:
3.1.409 [C:\Program Files\dotnet\sdk]
5.0.400 [C:\Program Files\dotnet\sdk]
5.0.401 [C:\Program Files\dotnet\sdk]
6.0.100-rc.1.21463.6 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
Microsoft.AspNetCore.All 2.1.29 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.29 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.1.15 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.1.18 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.1.19 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 5.0.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 5.0.10 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 6.0.0-rc.1.21452.15 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.1.29 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.10 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.15 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.18 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.19 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 5.0.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 5.0.10 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.0-rc.1.21451.13 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 3.1.10 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 3.1.13 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 3.1.15 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 3.1.18 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 3.1.19 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 5.0.9 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 5.0.10 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 6.0.0-rc.1.21451.3 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Details

Activity

  1. Tanya-Solyanik commented on Oct 5, 2021

    @Tanya-Solyanik
    Contributor

    DevExpress package used in the project probably does not have the Code designers.

        <PackageReference Include="DevExpress.Win.Reporting" Version="21.1.5" />
    
  2. MisinformedDNA commented on Oct 5, 2021

    @MisinformedDNA
    Author

    But the ones disappearing are a DataSet and a TableAdapter. Also, DevExpress has a pretty mature library, if there is a bug with their code, I'd love to be able to tell them what is wrong. I spent hours narrowing this down, so any help is much appreciated.

  3. MisinformedDNA commented on Oct 5, 2021

    @MisinformedDNA
    Author

    @Tanya-Solyanik I didn't want to edit the designer file for my repro, but I went ahead and did it. DevExpress is now removed as a dependency. I updated main and here's the new change commit. Same issue.

  4. RussKie commented on Oct 5, 2021

    @RussKie
    Contributor

    @MisinformedDNA have you contacted DevExpress?

  5. added
    waiting-author-feedback
    area-VSDesigner
    tracking-external-issue
    on Oct 5, 2021
  6. MisinformedDNA commented on Oct 5, 2021

    @MisinformedDNA
    Author

    @RussKie I shared a repro with DevExpress removed. It's clearly not them.

  7. ghost removed
    waiting-author-feedback
    on Oct 5, 2021
  8. MisinformedDNA commented on Oct 7, 2021

    @MisinformedDNA
    Author

    I've also tested this on VS 2019 and 2022 previews that do not have any DevExpress extensions installed.

  9. dreddy-work commented on Oct 8, 2021

    @dreddy-work
    Member

    @KlausLoeffelmann , can you take a look at the sample here and see anything stand out?

  10. MisinformedDNA commented on Oct 20, 2021

    @MisinformedDNA
    Author

    @KlausLoeffelmann Have you had a chance to look?

  11. MisinformedDNA commented on Nov 4, 2021

    @MisinformedDNA
    Author

    @KlausLoeffelmann @dreddy-work Can I get some help? How do I get this resolved?

  12. KlausLoeffelmann commented on Nov 4, 2021

    @KlausLoeffelmann
    Member

    Hey @MisinformedDNA,

    thanks for reporting that. We would need a repo which doesn't use a third party custom control, of which we don't know how compatible it is with the new designer.

    Please also note that Designer support for Typed DataSets is limited for .NET WinForms Apps, since the Data Source Provider Service (which are necessary for maintaining Typed DataSets and get the necessary components into a Form/UserControl on demand) is not available for .NET apps.

    That said, the most important scenarios we enabled (in WinForms! WPF is a different story, btw) without resorting to the Data Source Provider Service, so, I'd be interested if we can find a purely WinForms based scenario for this, since this would need to be fixed then!

  13. MisinformedDNA commented on Nov 4, 2021

    @MisinformedDNA
    Author

    @KlausLoeffelmann The project does not depend on a 3rd party, that dependency was removed Oct 5 (see above).

    The note about designer support for Typed DataSets is more of an FYI, since I'm using WinForms? Is that correct?

  14. 4 remaining items

  15. removed
    tracking-external-issue
    on Nov 4, 2021
  16. MisinformedDNA commented on Dec 1, 2021

    @MisinformedDNA
    Author

    @KlausLoeffelmann Any update?

  17. RussKie commented on Dec 2, 2021

    @RussKie
    Contributor

    @KlausLoeffelmann is currently OOF. With the holiday season is almost upon us our responses may be delayed.

  18. KlausLoeffelmann commented on Dec 2, 2021

    @KlausLoeffelmann
    Member

    That said, I know my debt, even watching my Mom-visiting-from-Germany backing Holiday cookies. Will take a while though, still... 🎅

  19. merriemcgaw commented on Feb 25, 2022

    @merriemcgaw
    Contributor

    @KlausLoeffelmann getting this back on your radar.

  20. KlausLoeffelmann commented on Feb 25, 2022

    @KlausLoeffelmann
    Member

    Follow up question:
    From your demo, I can't really see for component the generated code is swallowed.
    Can you provide the sample without any references to third party controls, so I can debug into the repo?

    Are you using a .NET Framework control by any chance in the context of a .NET (Core) application?

  21. added
    waiting-author-feedback
    on Feb 25, 2022
  22. removed
    waiting-on-team
    on Feb 25, 2022
  23. added this to the VS release milestone on Feb 25, 2022
  24. MisinformedDNA commented on Feb 27, 2022

    @MisinformedDNA
    Author

    You guys keep asking about a sample without third party controls, but the linked code in OP does not use any third party controls.

  25. ghost removed
    waiting-author-feedback
    on Feb 27, 2022
  26. merriemcgaw commented on Oct 23, 2024

    @merriemcgaw
    Contributor

    @Olina-Zhang can your team attempt a repro and close this if we don't see the issue any more?

  27. added
    untriaged
    on Oct 23, 2024
  28. removed
    untriaged
    on Jun 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

area-VSDesigner

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions