Skip to main content

How to Resolve Error "CS0432: Alias 'identifier' not found" in C#

The Compiler Error CS0432 is a scoping error involving the Namespace Alias Qualifier operator (::). The message reads: "Alias 'Name' not found".

In C#, the double-colon operator :: is reserved exclusively for navigating aliases (identifiers mapped to namespaces using using X = Y; or extern alias X;). If you place an identifier on the left side of :: (e.g., MyAlias::MyClass), the compiler looks specifically for a defined alias with that name. If it cannot find one—either because it wasn't defined, it is misspelled, or you are mistakenly trying to use a regular class name as an alias—CS0432 is triggered.

This guide explains how to define aliases correctly and when to use the dot operator . instead.

Understanding the :: Operator

The :: operator allows you to access a namespace via an alias without fear of naming collisions (e.g., if you have a class named System inside your project hiding the global System namespace).

  • Valid Left-Hand Side: Must be a defined alias (e.g., global, using MySys = System, or extern alias MyLib).
  • Invalid Left-Hand Side: Standard variable names, class names, or namespaces that haven't been aliased.

Scenario 1: Missing or Misspelled using Alias

This is the most common cause. You try to use an alias in your code, but the using directive at the top of the file is missing or has a typo.

Example of error

using System;

// We forgot to define: using Sys = System;

public class Program
{
static void Main()
{
// ⛔️ Error CS0432: Alias 'Sys' not found.
// The compiler looks for 'using Sys = ...' and doesn't find it.
Sys::Console.WriteLine("Hello");
}
}

Solution: Define the Alias

Add the missing directive at the top of the file.

using System;
// ✅ Correct: Define the alias explicitly
using Sys = System;

public class Program
{
static void Main()
{
// Now 'Sys' is a valid alias for the namespace 'System'
Sys::Console.WriteLine("Hello");
}
}

Scenario 2: Using :: like C++ (Scope Resolution)

Developers coming from C++ often use :: to access static members of a class (e.g., ClassName::MethodName). In C#, you use the dot operator (.) for this. The compiler throws CS0432 because it looks for an alias named ClassName, finds a class named ClassName instead, and reports that the alias wasn't found.

Example of error

public class Utilities
{
public static void Log() { }
}

public class Program
{
static void Main()
{
// ⛔️ Error CS0432: Alias 'Utilities' not found.
// 'Utilities' is a class, not an alias.
Utilities::Log();
}
}

Solution: Use the Dot Operator

Replace :: with ..

public class Program
{
static void Main()
{
// ✅ Correct: Standard C# member access
Utilities.Log();
}
}

Scenario 3: Missing extern alias Declaration

If you are using Extern Aliases to reference two versions of the same assembly (e.g., GridV1 and GridV2), you must declare them in your code even if they are configured in the project file.

Example of error

You configured the .csproj to map a DLL to GridV1, but you didn't tell the C# compiler to import it in this specific file.

// Missing: extern alias GridV1;

public class Report
{
public void Run()
{
// ⛔️ Error CS0432: Alias 'GridV1' not found.
var g = new GridV1::MyNamespace.Grid();
}
}

Solution: Add the Declaration

Add the extern alias statement at the very top of the file.

// ✅ Correct: Imports the alias defined in the project settings
extern alias GridV1;

public class Report
{
public void Run()
{
var g = new GridV1::MyNamespace.Grid();
}
}

Conclusion

CS0432 means you are using the double-colon syntax incorrectly.

  1. Check the Operator: Are you using :: when you meant .?
    • If accessing a class member, use ..
  2. Check the Alias: Did you define using MyName = ...?
  3. Check Spelling: Ensure the name on the left of :: matches your alias definition exactly.