Diagnose conflicting assembly names in a C# solution
A missing namespace error is not always a missing using directive. Two referenced projects can accidentally emit the same assembly name, leaving the consuming build without the distinct library it expects.
Check this specific cause after verifying the reference and type name. It is not a universal explanation for CS0246 or CS0234. Target-framework incompatibility, conditional compilation and inaccessible types need different repairs.
Reproduce the collision
Use the .NET 10 SDK and create an empty directory with Alpha, Beta and App subdirectories. Add these six files. A solution file is not required.
Alpha/Alpha.csproj:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<AssemblyName>Shared.Types</AssemblyName>
<PackageId>Example.Alpha</PackageId>
</PropertyGroup>
</Project>
Alpha/Feature.cs:
namespace Example.Alpha;
/// <summary>Supplies the alpha library's sample value.</summary>
public static class Feature {
public static string Value => "alpha";
}
Beta/Beta.csproj:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<AssemblyName>Shared.Types</AssemblyName>
<PackageId>Example.Beta</PackageId>
</PropertyGroup>
</Project>
Beta/Feature.cs:
namespace Example.Beta;
/// <summary>Supplies the beta library's sample value.</summary>
public static class Feature {
public static string Value => "beta";
}
App/App.csproj:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net10.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="../Alpha/Alpha.csproj" />
<ProjectReference Include="../Beta/Beta.csproj" />
</ItemGroup>
</Project>
App/Program.cs:
using System;
Console.WriteLine(Example.Alpha.Feature.Value);
Console.WriteLine(Example.Beta.Feature.Value);
The two library projects deliberately have different PackageId values so restore can distinguish them. They still both emit Shared.Types.dll with the same simple assembly name. Their C# namespaces are different, which does not resolve the assembly collision.
Build from the directory containing all three folders:
dotnet build App/App.csproj
In the tested SDK, this build fails with CS0234 reporting that Alpha does not exist in namespace Example. Which conflicting input wins resolution is not a contract to rely on. A different project graph or tool version may surface another missing-type or conflict diagnostic. Both libraries compile individually, so compiling only the producer projects does not reproduce the consuming failure.
Inspect the actual project property
dotnet msbuild Alpha/Alpha.csproj -getProperty:AssemblyName
dotnet msbuild Beta/Beta.csproj -getProperty:AssemblyName
Both commands initially print Shared.Types. Querying the evaluated property is useful when Directory.Build.props, imported targets or configuration-specific conditions override the value you see in a project file.
MSBuild's project-property reference
explains the output assembly name and property imports.
For a larger solution, inspect a diagnostic build or binary log to see resolved references and the paths selected by the consuming project. Retain the log locally because build logs can contain environment values and private paths. Microsoft's reference-resolution guidance explains that diagnostic path.
Give the libraries distinct identities
In Beta/Beta.csproj, change only its assembly-name property:
<AssemblyName>Example.Beta</AssemblyName>
Then run:
dotnet run --project App/App.csproj
Expected output:
alpha
beta
This repair leaves the namespaces and project references unchanged. Alpha still emits Shared.Types.dll, while Beta emits Example.Beta.dll. In an established product, choose stable descriptive names and assess assembly-qualified type names, reflection configuration and deployment consumers before renaming a shipped assembly.
Keep similar conflicts separate
A namespace organizes type names inside source and assemblies. AssemblyName identifies an output assembly. PackageId identifies a package for dependency management. Changing one does not automatically mean the others should change.
Two distinct assemblies can also expose the same fully qualified type name. That is a different ambiguity, for which extern alias may be appropriate. It should not be the first attempt to repair two projects accidentally presenting the same assembly identity.
If the failure remains after correcting the evaluated metadata, rebuild the consuming graph and inspect the resolved paths again. Clearing outputs can remove stale artifacts, but deleting caches without finding the naming conflict does not repair the contract. The example verifies command-line builds and execution. It does not claim that a Visual Studio designer has been tested.
Source and further reading
This article revisits the problem discussed in the following original answer. The explanation and examples here are newly written for .NET 10.
-
Herman Schoenfeld’s answer
on “The type or namespace name could not be found”, licensed under
CC BY-SA 3.0
.



Author: Herman Schoenfeld