CS0426: The type name 'Web' does not exist in the type 'ASP....

I've been having this problem with ASP.NET themes that block my web applications from working. I always get this error when opening any page: CS0426: The type name 'Web' does not exist in the type 'ASP.Foo'.

When I set the default language to vb (web.config > compilation tag), the exception message is even more cryptic: BC30002: Type 'Foo.Web.WebControls.MyWebControl' is not defined.

The problem was that I always use the following project setup:

  • Foo.Web: class library project containing web controls, base master pages, base pages, base user controls,...
  • Foo.WebApplication: web application project that references Foo.Web. I also register the controls globally in web.config (<pages><controls><add tagPrefix="foo" assembly="Foo.Web" namespace="Foo.Web.WebControls" />...) but the problem is also there if you register your controls locally.
  • Then in Foo.WebApplication I have defined a theme named "Foo" (in the App_Themes folder). I configure this theme globally in web.config (<pages styleSheetTheme="Foo">) but that shouldn't matter where it is configured.
  • In that theme I have a skin file (or several) that style one of my web controls from the Foo.Web project.

The problem is that at runtime the theme Foo is compiled in a namespace ASP.Foo, and then it will look for the namespaces Web.WebControls below that one, which isn't what I want. The only solution that I found is renaming the theme to something different, e.g. FooStyle.

I'm not sure whether this problem can also occur if you have an ASP.NET website, but I guess

No Comments