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

4 comments:

  1. I also named my asp.net project to DropDownlist and got the same error. The error disappeared after renaming it to DropDownListProject.

    Thanks a Lot

    ReplyDelete
  2. Changing Namespace name worked for me! Thanks

    ReplyDelete
  3. yeah its really worked for me and i learned one thing that we should not keep the name of project with any controls name

    ReplyDelete
  4. Thanks alot it worked for me as well:)

    ReplyDelete