errors while attempting to open the form in the designer Visual Studio Professional 2019

Darryl Hoar 116 Reputation points
2022-09-14T20:10:29.333+00:00

Greetings,
Tried opening a form that exists in my project. The designer opens with errors: "To prevent possible data loss before loading
the designer, the following errors must be resolved." It lists 6 errors like: Duplicate declaration of member 'label3", and 5 more
components.

I have looked in the myform.Designer.cs file and see only 1 declaration for label3. I opened myform.cs and there is no declaration for label3.
I looked in the resx, US.resx and BR.resx files and they look fine.

Where do I look to fix this problem ? It weird as I haven't changed this form in quite some time.

Thanks.

Developer technologies C#
{count} votes

Accepted answer
  1. Jack J Jun 25,296 Reputation points
    2022-09-20T08:46:03.273+00:00

    @Darryl Hoar , Welcome to Microsoft Q&A, based on the Gist you provided, I reproduced your problem.

    The problem is that you instantiated some controls 2 times.

    Please remove the following code for only one time in your designer.cs:

     this.panel15 = new System.Windows.Forms.Panel();  
      
     this.label3 = new System.Windows.Forms.Label();  
      
     this.anfcntLab = new System.Windows.Forms.Label();  
      
     this.label2 = new System.Windows.Forms.Label();  
      
     this.label1 = new System.Windows.Forms.Label();  
      
      this.listBox1 = new System.Windows.Forms.ListBox();  
    

    After removing these code, Please rebuild your project and you could see the form without the error:

    242941-image.png

    Best Regards,
    Jack


    If the answer is the right solution, please click "Accept Answer" and upvote it.If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.