Sequence contains no elements

Rob Sandham 20 Reputation points
2026-07-19T11:17:22.09+00:00

I'm using Visual Studio 2026 writing in VBasic.

3 times recently I have received the above error and I don't know what's wrong nor how to fix it. It happens when copying and renaming controls.

There's no help, and VS doesn't allow me to do further editing of the form.

I am going to have to abandon the 2026 version of VS until I know how to solve the problem.

Cheers.

Developer technologies | Windows Forms

Answer accepted by question author

Danny Nguyen (WICLOUD CORPORATION) 7,425 Reputation points Microsoft External Staff Moderator
2026-07-20T04:34:55.43+00:00

Hi @Rob Sandham ,

I'm sorry you're running into this frustrating issue. The "Sequence contains no elements" error is coming from the Visual Studio Windows Forms Designer. Since this started while copying and renaming controls, one possible cause is that a control name was not updated consistently in the generated .Designer.vb file.

Before making manual changes, please back up your project or commit your current changes to source control.

1. Check the .Designer.vb file

  • In Solution Explorer, select Show All Files if the designer file is not visible.
  • Expand your form, such as Form1.vb, and open Form1.Designer.vb.
  • Search for the control that was copied or renamed.
  • Check whether its name is consistent in the declaration, initialization, property assignments, and Controls.Add statements.
  • If you find an obvious mismatch between the old and new control names, correct it, save the file, and rebuild the project.

Avoid changing unrelated designer-generated code.

2. Clean and rebuild the solution

  1. Close the form designer.
  2. Select Build > Clean Solution.
  3. Select Build > Rebuild Solution.
  4. Reopen the form designer.

3. Clear the generated build files

If the issue continues:

  1. Close Visual Studio completely.
  2. Open the project folder in File Explorer.
  3. Delete the bin and obj folders.
  4. Reopen Visual Studio and rebuild the solution.

For more information, see Microsoft's Windows Forms design-time error troubleshooting guidance.

If you found my response helpful or informative, I would greatly appreciate it if you could follow this guidance or provide feedback.

Thank you. 

Was this answer helpful?

1 person found this answer helpful.
0 comments No comments

2 additional answers

Sort by: Most helpful
  1. Rob Sandham 20 Reputation points
    2026-07-21T09:31:31.4433333+00:00

    Thank you. This has helped considerably.

    Was this answer helpful?


  2. AI answer

    2026-07-19T11:17:45.1933333+00:00

    This usually points to a designer/cache or compile-state problem rather than a problem with the control copy operation itself. Since the form becomes non-editable in the designer, use this recovery path:

    1. Clean and rebuild the solution
      • In Visual Studio, select Build > Clean Solution.
      • Then select Build > Rebuild Solution.
      • If the designer error was caused by stale background data, this often clears it.
    2. Close Visual Studio and remove the solution cache
      • Close Visual Studio completely.
      • In the solution folder, rename or delete the hidden .vs folder.
      • Reopen the solution and let Visual Studio recreate it.
      • This is a safe cache reset and is specifically useful when the designer gets out of sync with the project.
    3. Check for compile errors across the whole project
      • The designer can fail to load when the project does not build cleanly.
      • Open Error List and fix all compile errors first.
      • Relevant Visual Basic compiler errors to look for include:
        • BC30451: a name is not declared
        • BC30930: a required element for compilation cannot be found
        • BC40057: an imported namespace or type cannot be found or has no public members
        • BC32300: object no longer exists due to compile error or deletion
    4. Inspect the form’s designer-generated code
      • Open the form’s .Designer.vb file.
      • Check the InitializeComponent method for controls that were copied/renamed and verify they still have valid declarations and initialization.
      • Look for missing control definitions or anything left in an invalid state.
    5. If the issue started after an update or keeps recurring, repair Visual Studio
      • Open Visual Studio Installer.
      • Select More > Repair for the installed Visual Studio instance.
    6. If the problem is specifically an inherited Visual Basic Windows Forms user control, there is a documented Visual Basic designer issue that was addressed by a hotfix in affected products.

    If the designer still cannot open after these steps, the most likely remaining cause is invalid designer-generated code in the renamed/copied controls, so checking InitializeComponent and then rebuilding is the best next step.


    AI-generated content may be incorrect. Read our transparency notes for more information.

    Was this answer helpful?

Your answer

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