C# "CS0234: namespace or type does not exist" (missing using) in CI
By Daniel Zoghalchali·Latchkey
CS0234 means the compiler found the parent namespace but not the requested sub-namespace or type inside it. It differs from CS0246 (the whole name is unknown): here the outer namespace resolves, so the gap is a missing nested using, a missing project reference, or a package the runner never restored.
What this error means
The build fails with CS0234 naming a namespace member, often suggesting a missing assembly reference. It reproduces every run because it is purely about references and using directives.
dotnet
Services/Auth.cs(7,17): error CS0234: The type or namespace name 'Json' does not exist
in the namespace 'System.Text' (are you missing an assembly reference?)
Diagnose it: SDK version and restore first
Most .NET CI failures are an SDK mismatch or a restore that did not happen. global.json pins the SDK, and if the runner does not have that exact version the failure message is about the project rather than the SDK.
Terminal
dotnet --info
cat global.json 2>/dev/null
# restore explicitly so a restore failure is not reported as a build failure
dotnet restore --verbosity normal
dotnet build --no-restore -warnaserror
Common causes
A using directive or package reference is missing
The code uses a type from a sub-namespace (e.g. System.Text.Json) whose package or framework reference is not declared, so the namespace exists but the member does not.
A project reference was not added
A type lives in a sibling project that the consuming project does not reference, so its namespace branch is invisible at compile time.
How to fix it
Add the missing reference or using
Identify which assembly or package owns the namespace member named in the error.
Add the PackageReference or ProjectReference that provides it.
Add the using directive (or rely on ImplicitUsings) and rebuild.
Enable ImplicitUsings to cover the common namespaces consistently.
Keep project references explicit and reviewed so namespace branches are always reachable.
Frequently asked questions
What causes C# "CS0234: namespace or type does not exist" (missing using) in CI?
There are 2 common causes: a using directive or package reference is missing and a project reference was not added. The code uses a type from a sub-namespace (e.g.
How do I fix C# "CS0234: namespace or type does not exist" (missing using) in CI?
Add the missing reference or using. Identify which assembly or package owns the namespace member named in the error.
What does C# "CS0234: namespace or type does not exist" (missing using) in CI actually mean?
The build fails with CS0234 naming a namespace member, often suggesting a missing assembly reference.
How do I stop C# "CS0234: namespace or type does not exist" (missing using) in CI happening again?
Enable ImplicitUsings to cover the common namespaces consistently. The prevention section lists 2 changes that keep it from recurring.