C# “已导入程序集相同的简单名称”错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14001185/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-10 10:20:59  来源:igfitidea点击:

"Assembly Same Simple Name already been imported" error

c#visual-studiodllnamespacesclr

提问by rbtLong

This is a CLR project. I'm importing two DLL files with the same name, quizz.dll(I rename the old version as legacyquizz.dll) and I include the newer version as quizz.dllinto a legacy converter test project. (The legacy converter project being tested only imports the old quizz.dll).

这是一个 CLR 项目。我正在导入两个同名的 DLL 文件quizz.dll(我将旧版本重命名为legacyquizz.dll),并将较新版本包含quizz.dll到旧转换器测试项目中。(正在测试的传统转换器项目仅导入旧的quizz.dll)。

This is the error I'm getting . . .

这是我得到的错误。. .

An assembly with the same simple name 'Quizz, Version=2.0.0.1, Culture=neutral, PublicKeyToken=null has already been imported.

Try removing one of the references or sign them to enable side-by-side. c:\ . . . \Quizz.dll

已导入具有相同简单名称 'Quizz, Version=2.0.0.1, Culture=neutral, PublicKeyToken=null 的程序集。

尝试删除其中一个引用或对其进行签名以启用并排。C:\ 。. . \测验.dll

The path it's pointing to is the destination of the newer version of quizz.dll.

它指向的路径是新版本 quizz.dll 的目标。

I'm using an external alias on the legacyquizz.dll file:

我在 legacyquizz.dll 文件上使用外部别名:

extern alias legacy;

What is a "simple name" in this context?

在这种情况下,什么是“简单名称”?

采纳答案by Gregor Primar

You can see the simple name by opening project properties and selecting Assembly Information:

您可以通过打开项目属性并选择程序集信息来查看简单名称:

enter image description here

在此处输入图片说明

To sign the assembly you need to select Signing tab and create or select signing key:

要对程序集进行签名,您需要选择 Signing 选项卡并创建或选择签名密钥:

enter image description here

在此处输入图片说明

回答by Robert Rouhani

You have two assemblies with the same name (not file name, assembly name). There are two solutions to this:

您有两个同名的程序集(不是文件名,程序集名称)。对此有两种解决方案:

  1. Rename one of the assemblies from the project's properties and recompile.
  2. Set up Strong-Name Signingon the assembly to allow two separate versions of the same assembly to coexist.
  1. 重命名项目属性中的程序集之一并重新编译。
  2. 在程序集上设置强名称签名以允许同一程序集的两个不同版本共存。

回答by Jilu_Simple_Powerfull_

I too seems this problem in my project. I had changed my dll path to another folder, and changed the reference path too for the same(dependency Layers). It will work. No duplication occurs.

我的项目中似乎也有这个问题。我已经将我的 dll 路径更改为另一个文件夹,并且也更改了相同的引用路径(依赖层)。它会起作用。不会发生重复。

回答by BlueStrat

If you are working with the new .csproj version, you may encounter this problem after you add a reference to another solution project, if the reference already exists as an Assembly Dependency (this reference may have been added automatically by Visual Studio).

如果您正在使用新的 .csproj 版本,则在添加对另一个解决方案项目的引用后,如果该引用已作为程序集依赖项存在(此引用可能已由 Visual Studio 自动添加),则可能会遇到此问题。

On Solution Explorer, expand the conflicting project, navigate to Dependencies->Assembliesand check that there is not an existing reference to the assembly that is raising the conflict. If it exists, just delete it and the conflict will be resolved.

在解决方案资源管理器上,展开冲突项目,导航到依赖项->程序集并检查是否存在对引发冲突的程序集的引用。如果存在,只需将其删除即可解决冲突。