C# Error CS1703 – Multiple assemblies with equivalent identity have been imported: ‘{0}’ and ‘{1}’. Remove one of the duplicate references.

C# Error

CS1703 – Multiple assemblies with equivalent identity have been imported: ‘{0}’ and ‘{1}’. Remove one of the duplicate references.

Reason for the Error & Solution

An assembly with the same simple name ‘name’ has already been imported. Try removing one of the references or sign them to enable side-by-side.

The compiler removes references that have the same path and file name, but it is possible that the same file exists in two places, or that you forgot to change the version number. This error points out that two references have the same assembly identity and thus the compiler has no way of distinguishing between them in metadata. Either remove one of the redundant references, or make the references unique somehow, such as by incrementing the assembly version number.

The following code generates error CS1703.

Example 1

This code creates assembly A in the .\bin1 directory.

Save this example in a file named CS1703a1.cs, and compile it with the following flags: /t:library /out:.\bin1\cs1703.dll /keyfile:key.snk

using System;  
public class A { }  

Example 2

This code creates a copy of assembly A in the .\bin2 directory.

Save this example in a file named CS1703a2.cs, and compile it with the following flags: /t:library /out:.\bin2\cs1703.dll /keyfile:key.snk

using System;  
public class A { }  

Example 3

This code references the assembly A in the two prior modules.

Save this example in a file named CS1703ref.cs, and compile it with the following flags: /t:library /r:A2=.\bin2\cs1703.dll /r:A1=.\bin1\cs1703.dll

extern alias A1;  
extern alias A2;  

Leave A Reply

Your email address will not be published. Required fields are marked *

You May Also Like

This C# program calculates and displays an upper triangular matrix based on user input. Problem Statement: The program takes the...
This C# program serves as a demonstration of bitwise operators, which are fundamental operators used for manipulating individual bits in...
This C# program is designed to interchange or swap the columns of a matrix. A matrix is a two-dimensional array...