Monday, June 8, 2020

Buggish: Visual Studio, "Element [elementName] is not a known element" warning

Visual Studio 2019

I get the errors below randomly. Suddenly while programming the ASP.NET page, my elements will suddenly have the green squiggly warning that my basic ASP elements are not known elements. I have yet to figure out the cause or reason for this to happen, but it does happen somewhat regularly perhaps once a week (of 10-20 hours of programming).

This is purely a syntactical bug, because I can still compile and run my program. It does not interfere with executing the project, but is super distracting. 

My Fix (Updated 9/2/2021)

Issue has increased a bit in the last month but still on the rare side. Fix is still to just close the ASPX page then re-opening. 

My Fix (Updated 4/29/2021)

For the last few months, I found that closing the ASPX page, then re-opening also resolves this issue. This is way faster than my workaround from June.

In the last couple months, I have to say that I haven't noticed this issue. Not sure if maybe I do it so reflexively that I do not notice or that it hasn't happened. I have thought about this until I was skimming over some older posts.

My Fix

1. Clean solution
2. Clean project
3. Restart Visual Studio 2019

I don't know why this fixes the problem. This is my current de facto fix and has worked for the last month. Before that, I some times skipped #1 or #2. Sometimes it worked, sometimes it didn't. Eventually, it just wasn't worth the time to skip one or the other.



  • Element [elementName] is not a known element
  • Element 'Button' is not a known element. This can occur if there is a compilation error in the Web site, or the web.config file is missing.
  • Element 'GridView' is not a known element. This can occur if there is a compilation error in the Web site, or the web.config file is missing.
  • Element 'TextBox' is not a known element. This can occur if there is a compilation error in the Web site, or the web.config file is missing.

Reference

Personal experience

No comments:

Post a Comment