C# "CS0234: namespace or type does not exist" (missing using) in CI
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.
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?)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
PackageReferenceorProjectReferencethat provides it. - Add the
usingdirective (or rely on ImplicitUsings) and rebuild.
<ItemGroup>
<PackageReference Include="System.Text.Json" Version="8.0.4" />
</ItemGroup>How to prevent it
- Enable
ImplicitUsingsto cover the common namespaces consistently. - Keep project references explicit and reviewed so namespace branches are always reachable.