blazorvisual-studio-2022

VS2022 ignores new component added into the project


Using VS2022 v 17.10.4 When I add a new component into the project , VS ignores its existence. I have to close VS, delete the obj and the bin folders, reopen VS, clear and rebuild the solution and it works for awhile until it happens again. In the picture below, it shows that it does not detect the error in the form. It compiles and run. Depending on what part of the project I am working on, it can take me a lot of time to figure that the problem is in this newly added form where the added context is being ignored by VS

enter image description here


Solution

  • If you encounter the following situation: the newly added components cannot be recognized in time or the newly added code and forms cannot be recognized by the compiler in time. In similar situations, you can try to clean up the VS cache in the following location according to @mrSoh's suggestion: %LocalAppData%\Microsoft\VisualStudio\<Version>\ComponentModelCache, and then restart VS.

    The reason for this is that when we operate on project files in VS (add, delete or modify), the IDE itself will maintain an internal cache to speed up file loading and project compilation, but sometimes this cache will be damaged or inconsistent, causing problems with the project.