Friday, September 10, 2010

CS0426: The type name XXX does not exist in the type XXX

Yesterday, I was getting below error continously when I was working on a sample of MasterPage.

CS0426: The type name 'MyMaster' does not exist in the type 'System.Web.UI.WebControls.TreeView'

While I tried a lot many things (deleting page, adding new etc.) and also googled couple of things, but could not get any clue. Later while reading a post I realized the problem.

Problem here was that I had named my project (and thereby assembly and the namespace) as TreeView. So at runtime, the CLR was trying to find my master page inside Sytem's standard treeview class.

So solution was simple i.e. just change the project and namespace name to a non reserved work like TreeviewPOC in my case.

So next time you get CS0426 error, just check if your namespace or project name is colliding with any of the standard (or even third party controls etc).

Happy Coding

Regards, Subhash Dike