There’s more than one way to get an error message and I found a brilliant way to get this one.
Get this. It can come about when the Start Page of your .NET Project contains a @Register Directive to a UserControl which does not compile.
And now the embarassing part: the confession
So we have this .NET Project which contains Factory Classes which load a different set of UserControls, and Data Access Objects depending on which region is configured in web.config.
But the code written for the Jyvaskyla region (JV) is old and is not intended to be executed so we unload the JV folder from the Project before compilation. But one of the pages Dog.aspx Registers the Jyvaskyla DogBreath control which itself inherits from BaseUserControl. Like so:
%@ Register Src=”~/JV/Controls/DogParts/DogBreath.ascx” TagName=”JVDogBreath” TagPrefix=”uc2″ %
…and in my newbie ignorance to this particular .NET Project I thought that Dog.aspx was the Visual Studio Start Page for the Projec, so that’s what I selected from the Solution Explorer Context Menu.
When I hit F5 to run the Project Dog.aspx was loaded and it went on to register the magnificent JVDogBreath control which it couldn’t because the @Register Directive syntax above forces a dynamic compile of the source code, which as I told you before, does not compile.
And why doesn’t it compile ?
As the error message said, missing namespace for its base class, ‘BaseUserControl’.
The source code for the JVDogBreath starts off like so:
public class JVDogBreath : BaseUserControl
That doesn’t compile necause BaseUserControl was not referenced properly. Since it lives in the BaseDogParts namespace it should have been:
public class JVDogBreath : BaseDogParts.BaseUserControl
or else in my usings…
Yeah, so I was ambushed by a redundant @Register Directive in combination with me setting the wrong Start Page.