[SOLVED] I’m getting a CS0234 “The type or namespace name “Services” does not exist in the namespace” even though I can see it in file structure

Issue

This Content is from Stack Overflow. Question asked by user20027912

I was following a tutorial from Microsoft found at https://learn.microsoft.com/en-us/training/modules/create-razor-pages-aspnet-core/

At one point it instructs to add a folder under the root project called “Services”. Within that folder is a file which needs to be accessed. Upon creating the project, another folder called “Models” was automatically created under the root folder.

I include the two lines at the top of another file:
using RazorPagesDoughnuts.Services; using RazorPagesDoughnuts.Models;

The Models statement works no problem. The Services statement generates the error. I have searched many resources and cannot find a solution.

I am using vscode 1.71.2 and .net 6.0

Screenshot of file structure and statements



Solution

The namespace provided in the file DoughnutService.cs is probably not correct. Change that to RazorPagesDoughnuts.Services and check.


This Question was asked in StackOverflow by user20027912 and Answered by WisdomSeeker It is licensed under the terms of CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.

people found this article helpful. What about you?