Skip to content
Latchkey

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.

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?)

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

  1. Identify which assembly or package owns the namespace member named in the error.
  2. Add the PackageReference or ProjectReference that provides it.
  3. Add the using directive (or rely on ImplicitUsings) and rebuild.
csproj
<ItemGroup>
  <PackageReference Include="System.Text.Json" Version="8.0.4" />
</ItemGroup>

How to prevent it

  • 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 ""CS0234: ... does not exist in the namespace""?
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.
How do I fix "CS0234: ... does not exist in the namespace"?
Add the missing reference or using

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card