Winforms Designer - code from inherited controls is not removed

When I change the inheritance of a winform to a baseform with components on it: works perfect.
When I change it back to inherit from System.Windows.Forms.Form, the generated code for the inherited components is not removed from the designer file, causing the designer to crash at open.

Question: Why is this code generated at the first place? - It is designed and maintained in the base form, not in the inherited form.

Thanks, logged as bugs://80387

Hello Theo,

Could you please provide me with the video or any steps on how to reproduce the problem. I tried to create 2 forms in the project, put some componentes on one of them, inherited the second one from the first, compiled project, opened and closed designer - everything is fine. Then I changed inherited type into Form again, reopened the designer - still no crash, project compiles fine.

Best regards.

Maybe the tablelayout panel (doc fill, with components on it) is the problem (on the base form).
Inherit, resize the inherited form. At that moment location properties for the inherited controls are generated in the inherited form. When you then revert to windows form, it does not know the inherited controls anymore.

Extra info:
The generated code in the designer file is created as self.
instead of inherited.

Theo,

I am afraid I cannot fix an issue without reproducing it here. I have done next steps:
1, An application with 2 forms: MainForm and BaseForm1.
2. I inherited MainForm from BaseForm1 as:
MainForm = partial class(BaseForm1)
3. I put TableLayoutPanel on the BaseForm1, made Dock = Fill and put a button on that panel.
3. Then I resized the BaseForm1 and saved the project.
4. I rebuilded the project and opened MainForm1. The designer is shown with controls from the BaseForm1 as expected.
5. Then I opened the MainForm code and changed inheritance back to System.Windows.Forms.Form. Saved the project and rebuilded it again - build was done with no errors.
6. I opened the MainForm and got proper designer shown, no errors,
Could you please provide me with the video on what you are doing to reproduce the error.

Thanks in advance.

Hi Viktoriad,

Try it with the same project as the previous bug.

Regards,
Theo

Hello Theo,

I reproduced the problem with your project. But the same situation happens if I do the steps with MS C# Winforms. This code comes from Winforms itself, and same code is inserted in MS C# winforms. It’s not something that we can control.

Ok, clear.