Visual studio keeps saying "Make sure that the class defined in this code file matches the 'inherits' attribute"

Ever time I built my ASPX c# project the build would give an error saying:

"Make sure that the class defined in this code file matches the 'inherits' attribute"

I check and it did, I deleted the file and recreated it and still the same problem.The compiler was talking rubbish, and it was delaying me when I was debugging.

I copied and pasted the <%@ Page tag, and check it.

Eventually I though to myself lets think out the box here. It is telling us it does not match, what are the options:

  • The page used to have and _default the definition and somewhere in the project it is finding it (so I did a porject wide search for these, and I did find a few funnies, re built and still same friggin error.
  • The I though lets look for a file that is also referring to the background file, I had copied and pasted a few things, perhaps that was the problem, so I did a search the the full name of the CodeFile, and that is when I found that another page I had renamed had not had that reference renamed, only the class.

Sometime you need to look at a error in a funny way with your eye squint, to really understand the error. Why does the complier not tell you which aspx page is referring the class, silly thing

Comments