HomeCSharpC# Error CS1704 – An assembly with the same simple name ‘{0}’ has already been imported. Try removing one of the references (e.g. ‘{1}’) or sign them to enable side-by-side.

C# Error CS1704 – An assembly with the same simple name ‘{0}’ has already been imported. Try removing one of the references (e.g. ‘{1}’) or sign them to enable side-by-side.

C# Error

CS1704 – An assembly with the same simple name ‘{0}’ has already been imported. Try removing one of the references (e.g. ‘{1}’) or sign them to enable side-by-side.

Reason for the Error & Solution

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

This error points out that two references have the same assembly identity because the assemblies in question lack strong names, they were not signed, and thus the compiler has no way of distinguishing between them in metadata. Thus, the run time ignores the version and culture assembly name properties. The user should remove the redundant reference, rename one of the references, or provide a strong name for them.

Example 1

This sample creates an assembly and saves it to the root directory.

// CS1704_a.cs  
// compile with: /target:library /out:c:\\cs1704.dll  
public class A {}  

Example 2

This sample creates an assembly with the same name as the previous sample, but saves it to a different location.

// CS1704_b.cs  
// compile with: /target:library /out:cs1704.dll  
public class A {}  

Example 3

This sample attempts to reference both assemblies. The following sample generates CS1704.

// CS1704_c.cs  
// compile with: /target:library /r:A2=cs1704.dll /r:A1=c:\\cs1704.dll  
// CS1704 expected  
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...