Thursday, April 17, 2014

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

This is a short note on the error message. I googled and none of those matched exactly what I did and none of them solved my problem.

Since each development is different and many situation can raise the same error message. It is, therefore, important to describe my setups in order to be useful to my blogger readers.

First of all, I am hand coding my code for the sack of purities. It should apply well to cases where more complicated environment is used.

I created a user control with code behind: .ascx and .cs. I then use this user control in my web page: MyPage.aspx and MyPage.cs. For page derived .cs files, you will need to declare variables for controls that you used in MyPage.aspx. I can declare those variables for all the standard web controls. However, when I declared variable for my user control, the error message result. I did employed namespace for my user control and I did 'using' that namespace. However, the IIS Express wouldn't recognize my control until I explicitly declare the variable with full-namespace specification.

As with my previous post concerning IIS Express, this problem could be just the IIS Express issues. Even though, some of the Internet posts may suggest otherwise.

No comments:

Post a Comment