Compiler Error CS0434
The namespace NamespaceName1 in NamespaceName2 conflicts with the type TypeName1 in NamespaceName3
This error occurs when an imported type and an imported nested namespace have the same fully qualified name. When that name is referenced, the compiler is unable to distinguish between the two. If you can change the imported source code, you can resolve the error by changing the name of either the type or the namespace so that both are unique within the assembly.
The following code generates error CS0434.
This code creates the first copy of the type with the identical fully qualified name.
// CS0434_1.cs
// compile with: /t:library
namespace TypeBindConflicts
{
namespace NsImpAggPubImp
{
public class X { }
}
}
This code creates the second copy of the type with the identical fully qualified name.
// CS0434_2.cs
// compile with: /t:library
namespace TypeBindConflicts {
// Conflicts with another import (import2.cs).
public class NsImpAggPubImp { }
// Try this instead:
// public class UniqueClassName { }
}
This code references the type with the identical fully qualified name.
// CS0434.cs
// compile with: /r:cs0434_1.dll /r:cs0434_2.dll
using TypeBindConflicts;
public class Test
{
public TypeBindConflicts.NsImpAggPubImp.X n2 = null; // CS0434
}
.NET feedback
.NET is an open source project. Select a link to provide feedback: