You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/csharp/language-reference/compiler-messages/cs0433.md
+17-9Lines changed: 17 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,7 +14,7 @@ The type TypeName1 exists in both TypeName2 and TypeName3
14
14
15
15
Two different assemblies referenced in your application contain the same namespace and type, which produces ambiguity.
16
16
17
-
To resolve this error, use the alias feature of the ([**References**](../compiler-options/inputs.md#references)) compiler option or do not reference one of your assemblies.
17
+
To resolve this error, use the `extern alias` feature with project reference aliases or do not reference one of your assemblies. You can also use the alias feature of the ([**References**](../compiler-options/inputs.md#references)) compiler option when compiling directly with the C# compiler.
18
18
19
19
This error can also occur if:
20
20
@@ -27,7 +27,7 @@ This error can also occur if:
27
27
28
28
```csharp
29
29
// CS0433_1.cs in CS0433_1.csproj
30
-
//or compile with: /target:library
30
+
// compile with: dotnet build or /target:library
31
31
namespaceTypeBindConflicts
32
32
{
33
33
publicclassAggPubImpAggPubImp { }
@@ -38,14 +38,14 @@ namespace TypeBindConflicts
38
38
39
39
```csharp
40
40
// CS0433_2.cs in CS0433_2.csproj
41
-
//or compile with: /target:library
41
+
// compile with: dotnet build or /target:library
42
42
namespaceTypeBindConflicts
43
43
{
44
44
publicclassAggPubImpAggPubImp { }
45
45
}
46
46
```
47
47
48
-
So, when consuming these two libraries (`CS0433_1.dll` and `CS0433_2.dll`) in the project, using the `AggPubImpAddPubImp` type will be ambiguous and will lead to compiler error `CS0433`.
48
+
So, when consuming these two libraries (`CS0433_1.dll` and `CS0433_2.dll`) in the project, using the `AggPubImpAggPubImp` type will be ambiguous and will lead to compiler error `CS0433`.
// compile with: dotnet build or /reference:cs0433_1.dll /reference:cs0433_2.dll
59
59
usingTypeBindConflicts;
60
60
61
61
publicclassTest
@@ -67,7 +67,11 @@ public class Test
67
67
}
68
68
```
69
69
70
-
The following example shows how you can use the alias feature of the **/reference** compiler option or `<Aliases>` feature in `<ProjectReference>` to resolve this CS0433 error.
70
+
The following example shows how you can use the `extern alias` feature with project references to resolve this CS0433 error. This is the recommended approach for modern .NET projects.
71
+
72
+
### Step 1: Add an alias to one of the project references
73
+
74
+
First, modify your project file to add an alias to one of the conflicting project references:
0 commit comments