Botbuilder-dotnet: Azure Storage Name Space Collision

Created on 15 Mar 2019  路  6Comments  路  Source: microsoft/botbuilder-dotnet

Language: C#

Description

Microsoft.AspNetCore references Microsoft.WindowsAzure.Storage while Microsoft.Bot.Builder.Azure references Microsoft.Azure.Storage.Blob having same namespace, and same object type name so attempting to reference 'CloudBlockBlob' in my bot code results in the following complier error.

Compiler Error: The type 'CloudBlockBlob' exists in both 'Microsoft.Azure.Storage.Blob, Version=9.4.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' and 'Microsoft.WindowsAzure.Storage, Version=8.1.4.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'

I haven't yet figured out a work around. Any ideas?

To Reproduce

  1. Create new project from Enterprise Bot Template v0.3
  2. Add code:
    c# using Microsoft.WindowsAzure.Storage; using Microsoft.WindowsAzure.Storage.Blob; . . . string sasUri = $"{storageConfig.ContainerName}{storageConfig.ConnectionString}"; CloudBlobContainer container = new CloudBlobContainer(new Uri(sasUri)); CloudBlockBlob blob = container.GetBlockBlobReference(blobName);

I've tried to reference Microsoft.Azure.Storage instead, but without success.

Expected behavior

Project compiles without namespace conflict error

Screenshots

Current version Enterprise Bot dependencies
image

Prior version Enterprise Bot dependencies
image

Additional context

Similar issue is discussed here,
https://github.com/Azure/azure-storage-net-data-movement/issues/159

4.4 P0 bug triaged

All 6 comments

Hi @markbeau it looks like the WindowsAzure.Storage package has been split up and the Microsoft.Azure.Storage approach is the latest, but the Microsoft.AspNetCore.All package has not been updated to reflect this.

I wasn't able to find a workaround on my side so I'm going to transfer this to the SDK team. They might have run into this problem before.

Thanks to @blueww for suggesting a workaround I'd never have found on my own.
See: https://github.com/Azure/azure-storage-net-data-movement/issues/166#issuecomment-471811117

I added the following to my .csproj file:

  <Target Name="ChangeAliasesOfStrongNameAssemblies" BeforeTargets="FindReferenceAssembliesForReferences;ResolveReferences">
    <ItemGroup>
      <ReferencePath Condition="'%(FileName)' == 'Microsoft.Azure.Storage.Blob'">
        <Aliases>xsclblob</Aliases>
      </ReferencePath>
      <ReferencePath Condition="'%(FileName)' == 'Microsoft.Azure.Storage.Queue'">
        <Aliases>xsclqueue</Aliases>
      </ReferencePath>
      <ReferencePath Condition="'%(FileName)' == 'Microsoft.Azure.Storage.File'">
        <Aliases>xsclfile</Aliases>
      </ReferencePath>
      <ReferencePath Condition="'%(FileName)' == 'Microsoft.Azure.Storage.Common'">
        <Aliases>xsclcommon</Aliases>
      </ReferencePath>
      <ReferencePath Condition="'%(FileName)' == 'Microsoft.WindowsAzure.Storage'">
        <Aliases>xsclold</Aliases>
      </ReferencePath>
    </ItemGroup>
  </Target>

Then where I make my Azure Blob Storage calls:
```C#
extern alias xsclcommon;
extern alias xsclblob;

using xsclcommon::Microsoft.WindowsAzure.Storage;
using xsclblob::Microsoft.WindowsAzure.Storage.Blob;
. . .
```

This allows me to keep moving forward while the Azure Storage references in Microsoft.AspNetCore.All are worked out.

Hi @markbeau, can you try the steps I outlined in #1421 and let me know if that fixes your issue?

Starting with ASPNet Core 2.1, we should be referencing Microsoft.AspNetCore.App instead of Microsoft.AspNetCore.All (details here)

Hi @markbeau, a fix for the new template will be released once the PR lined above is merged in to master, to fix your project today, follow the instructions outlined in #1421.

Thanks

Hi @gabog, just changing the "Microsoft.AspNetCore.All" include reference in .csproj per https://github.com/Microsoft/botbuilder-dotnet/issues/1421 did the trick.

  <PackageReference Include="Microsoft.AspNetCore.App" />

Thanks for your help chasing this down.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

drub0y picture drub0y  路  5Comments

lauren-mills picture lauren-mills  路  6Comments

MarceloRGonc picture MarceloRGonc  路  6Comments

cmayomsft picture cmayomsft  路  6Comments

ivorb picture ivorb  路  6Comments