Why are all my controls suddenly throwing errors, but still working?

Abby Baratta 0 Reputation points
2024-06-20T18:32:35.3866667+00:00

Hello,

I am relatively new to the .NET framework and I'm creating my first real project. It was working smoothly until earlier today when I was messing around with adding a sub that runs on load. I a sub working on load on a practice project that I made before and I followed the same steps.

All of a sudden, all my controls threw errors saying: Control is not declared. It may be inaccessible due to its protection level.

I tried debugging my program and it ran perfectly. No errors and no odd behavior. The sub that runs on load ran alright and every button and box I checked did exactly what it was supposed to.

Technically everything works, but it's incredibly difficult to try and write more without VS recognizing my controls. I tried closing the project and reopening it like Google said, but that did not work. I checked with my original test project and that one didn't have any errors on the controls, so it just seems to be this one.

Does anyone know why this may be happening?

Visual Studio
Visual Studio
A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.
4,793 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Tianyu Sun-MSFT 28,846 Reputation points Microsoft Vendor
    2024-06-21T03:38:35.4166667+00:00

    Hello @Abby Baratta ,

    Welcome to Microsoft Q&A forum.

    Please try to clean your project cache first.

    Delete the bin, obj and the hidden .vs folder in your solution/project folder, rebuild your project.

    It was working smoothly until earlier today when I was messing around with adding a sub that runs on load.

    I think this is the key information. Not sure what you have done, maybe something like files, assemblies, frameworks, packages were added, modified and cause this issue.

    If you check your project, maybe structure, referenced packages/assemblies, and project file(.csproj file), can you find any wrongly set configurations, or invalid configurations?

    Best Regards,

    Tianyu


    If the answer is the right solution, please click "Accept Answer" and kindly 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.

    0 comments No comments