1

Our dot net core 2.0 project has some classes that implement ICloneable (they have a .Clone() method that returns an object). Now, we are using a package Microsoft.Azure.Amqp and when building the project now gives an error:

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'

Both have ICloneable in the "System" namespace, so how can the compiler know which one to use? Is there a way to say which DLL to use for that reference?

DenverCoder9
  • 1,119
  • 3
  • 16
  • 30

1 Answers1

0

The question here has a solution to this problem. I'll summarise it briefly. Go to the reference in your project, and change "Aliases" to a value of your choosing. To use code from this assembly now, you will need to use the extern keyword like so at the top of your file: extern alias aliasname. Then you can reference code from this assembly like so: aliasname::System.ICloneable.

Lauraducky
  • 674
  • 11
  • 25