Fleezus Christ Fleezus Christ - 18 days ago 8
C# Question

CS0426 - The type name { } does not exist in the type { }

Today I worked at my project and suddenly the following error ris:


CS0426 The type name 'CustomerView' does not exist in the type 'PetrolStation'


I have no clue what is going on here:

My Solution in VisualStudio

I think that image shown above is pretty self explaining. You may notice that the same error happens also a code-block further down with the error:


CS0426 The type name 'Views' does not exist in the type 'PetrolStation'


And the same error here again:

My Solution in VisualStudio

Which raises the following error:


CS0426 The type name 'App' does not exist in the type 'PetrolStation'


Does anyone know what is going on here?

Thanks

Answer

If your class is defined in PetrolStation namespace you shouldn't specify this namespace if you try to access to this class. Delete PetrolStation namespaces before class names:

App app = new App(); //and in other places without PetrolStation

OR

If you've created class with the same name as namespace you should specify full name:

PetrolStation.PetrolStation.App app = new PetrolStation.PetrolStation.App(); //and in other places with one more PetrolStation

It seems to be the first case in your code.

Comments