Bogus errors from ASP.NET compiler

by Christoph Herold 18. März 2009 17:43

I just wasted another hour, trying to figure out, what exactly ASP.NET was trying to tell me, when giving me an "ASPNET: Make sure that the class defined in this code file matches the 'inherits' attribute, and that it extends the correct base class (e.g. Page or UserControl)." message on compiling my ascx file.

Ok, so I used a custom namespace, but I've done that hundreds of times, so that shouldn't be the problem. I also had a custom base class inheriting from UserControl. Also, nothing I haven't done before. So what was the issue now?!

I basically retyped everything concerning the namespace and class names in all files, but nothing helped. So I reverted to commenting out my code. This helped me find the issue: I used a

<% if (somethingOrOther) { %> Some code here <% } %>

construct in my ascx-file (Please don't start an argument on whether this is good practice or not. I know it's not the cleanest way to do things, but that is not the concern here :-) ), and actually forgot to put in the closing <% } %>. Ok, my fault, but shouldn't you get a better Compiler message than "ASPNET: Make sure that the class defined in this code file matches the 'inherits' attribute, and that it extends the correct base class (e.g. Page or UserControl)."?!

So, if you encouter this error (and believe me, I've had it more than once due to typos), and are 100% positive you've spelled everything correctly, check for unbalanced parentheses!

Tags: , , , ,

Development

Month List

Impressum (for the Germans)

Christoph Herold

Dieses Weblog wird bereitgestellt und verwaltet durch

Christoph Herold
Ignaz-Semmelweis-Str. 37
41540 Dormagen
Deutschland

Sie erreichen mich unter christoph.herold@coeamyd.net.