0

I've defined the following variable:

var x = Microsoft.WindowsAzure.Storage.Blob.StandardBlobTier.Hot;

But the compiler is returning the following error:

Error CS0433 The type 'StandardBlobTier' exists in both 'Microsoft.Azure.Storage.Blob, Version=9.4.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' and 'Microsoft.WindowsAzure.Storage, Version=9.1.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'

I don't think I've ever seen a type conflict error like this occur after specifiying a fully-qualified class name. Any idea what the root cause of this error might be or how to fix?

UPDATE

Here's some more interesting info. The y var below is being set to a fully qualified reference of the stated conflicting type but the compiler is telling me that the conflicting type doesn't exist!:

var x = Microsoft.WindowsAzure.Storage.Blob.StandardBlobTier.Hot;
var y = Microsoft.Azure.Storage.Blob.StandardBlobTier.Hot;

This seems confusing

  • 1
    Looks like you are building against two incompatible versions of the blob library; if you read the notes, they point out that this is a breaking change. https://github.com/Azure/azure-storage-net/blob/master/Blob/BreakingChanges.txt This looks to me like a symptom of your build system being misconfigured. – Eric Lippert Jan 22 '19 at 19:58

3 Answers3

0

You have 2 versions of that type available to your application. You could change your reference in your project to use 'Specific Version'. See: How exactly does the "Specific Version" property of an assembly reference work in Visual Studio?

Jonathan
  • 4,916
  • 2
  • 20
  • 37
0

Microsoft.Azure.Storage.DataMovement (DMlib), is based on WindowsAzure.Storage So when you install DMlib, you must install WindowsAzure.Storage.

Microsoft.Azure.Storage.Blob is part of the new XSCL that spilt to differenct lib to support B/F/Q...

Old WindowsAzure.Storage and new Microsoft.Azure.Storage.Blob have same namespace and same object type name.

So when you use them together, you will get that exception.

NaDeR Star
  • 647
  • 1
  • 6
  • 13
0

I am not an expert in this issue, but as I noted in a comment, my suspicion would immediately be that your build system is referencing multiple incompatible versions of an evolving library, and that the fix should go there. Stop referencing two versions of an evolving library.

To answer the more general problem: when you are in the unfortunate situation that you have two libraries and they both have the exact same class name, you can solve the problem by making an extern alias:

https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/extern-alias

Eric Lippert
  • 647,829
  • 179
  • 1,238
  • 2,067