【问题标题】:ICloneable Exists in Two AssembliesICloneable 存在于两个程序集中
【发布时间】:2017-12-04 13:30:04
【问题描述】:

我们的 dot net core 2.0 项目有一些实现ICloneable 的类(它们有一个返回object.Clone() 方法)。现在,我们正在使用一个包Microsoft.Azure.Amqp,现在在构建项目时出现错误:

Error CS0433 The type 'ICloneable' exists in both 'Microsoft.Azure.Amqp, Version=2.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' and 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'

两者在“System”命名空间中都有ICloneable,那么编译器怎么知道要使用哪一个呢?有没有办法说明该引用使用哪个 DLL?

【问题讨论】:

    标签: c# .net asp.net-core-2.0


    【解决方案1】:

    问题here 有解决这个问题的办法。我将简要总结一下。转到项目中的引用,并将“别名”更改为您选择的值。现在要使用此程序集中的代码,您需要在文件顶部使用 extern 关键字:extern alias aliasname。然后你可以像这样引用这个程序集中的代码:aliasname::System.ICloneable

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-11-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多