This is a fun problem I ran into, luckily I solved it rather quickly.

The Setup

I have a website setup in IIS7.5 running on a .Net 2.0 application pool and I just added a virtual directory to it so I could add another application to the website running under a .Net 4.0 application pool. The website has its own web.config obviously and anything (applications) under the website’s umbrella will inherit from the website’s web.config by default.

I had to blank out some stuff for job security reasons. Sorry.

I was getting the yellow screen of death, name this error:

CS0246: The type or namespace name ‘NameHere’ could not be found (are you missing a using directive or an assembly reference?)

As you can see in the image it is complaining about the parent web.config and not the actual application web.config.

After looking at the website’s web.config I noticed that it was clearing all namespaces prior to listing its own like below:

Website’s Web.Config <pages /> Node

Missing example - lost when porting from Blogger.

So noticing that, I took that same concept and put it into my own web.config like below.

The New Virtual Directory (Application) Web.Config <pages /> Node

Missing example - lost when porting from Blogger. 

Viola! Problem solved. This is certainly not a cure all for everyone’s CS0246 problems, but it is definitely one of them. Kind of Obscure and not necessarily clear…

Leave a Reply

Your email address will not be published. Required fields are marked *