CS0246 .NET Origin: Application & API Last updated 13 Oct 2026

error CS0246: The type or namespace name 'X' could not be found (are you missing a using directive or an assembly reference?)

The compiler doesn’t know the type — missing using, missing NuGet package/project reference, or a target framework mismatch.

Exact message you may see The type or namespace name could not be foundare you missing a using directive or an assembly reference
Seen on: .NET

Meaning

After moving code between projects, the reference or package often isn’t added. Packages that don’t support the target framework also produce CS0246 after restore warnings.

Common causes

  • Missing using directive
  • NuGet package/project reference not added
  • Package doesn’t support the target framework
  • Typo or wrong casing

⚡ Quick fix

  1. Add the using or reference (dotnet add package/reference)
  2. Restore and check warnings (NU1701, NU1202)
  3. Check the type’s namespace

Detailed fix by platform

Shell

  1. csharp
    dotnet add package Newtonsoft.Json
    dotnet add reference ../App.Core/App.Core.csproj
    dotnet restore

How to diagnose

  1. Namespace — Where is the type?
  2. References — Package/project referenced?
  3. Framework — Supported?

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

Where this error sits

Origin: Application & API. Errors that are often confused with or caused by this one (click to open):

CS0103 — error CS0103: The name 'x' does not exist in the current context (.NET)CS0103CS1061 — error CS1061: 'X' does not contain a definition for 'Y' and no accessible extension method 'Y' accepting a first argument of type 'X' could be found (.NET)CS1061CS8618 — warning CS8618: Non-nullable property 'X' must contain a non-null value when exiting constructor. Consider declaring the property as nullable (.NET)CS8618declared and not used — Go: declared and not used: x / "fmt" imported and not used (Go)declared and not usedE0308 — Rust: error[E0308]: mismatched types — expected `X`, found `Y` (Rust)E0308NU1101 — error NU1101: Unable to find package X. No packages exist with this id in source(s): nuget.org (.NET)NU1101Reference to undeclared resource — Terraform: Error: Reference to undeclared resource / Reference to undeclared input variable (Terraform)Reference to undeclar…The request matched multiple endpoints — AmbiguousMatchException: The request matched multiple endpoints. Matches: X, Y (.NET)The request matched m…CS0246

Explore the map of this error Full error map →

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.

💬 What worked for others

No tips yet — did something else fix this for you?

Share what worked for you

Tips are checked by an editor before they appear. Links are removed.