【发布时间】:2018-01-28 06:53:46
【问题描述】:
我将我的网络应用程序从 .Net 4.0 升级到了 .Net 4.5.2,但出现了一个我找不到解决方案的错误。它在与 Azure Blob 存储的任何接口期间。我删除了所有 NuGet 包并在 4.5.2 下再次添加它们。错误信息是:
错误 BC30456“CreateCloudBlobClient”不是“CloudStorageAccount”的成员。
进口:
Imports Microsoft.WindowsAzure
Imports Microsoft.WindowsAzure.Storage.Blob
Imports System.IO
Imports System.Data.SqlClient
代码:
Private _Account As CloudStorageAccount
Private _ImageContainerName As String = ""
Private _ConnectionString As String = ""
Public Sub New(storageEndpoint As String, imageContainerName As String, Optional ByVal connStr As String = "")
_Account = CloudStorageAccount.Parse(storageEndpoint)
_ImageContainerName = imageContainerName
_ConnectionString = connStr
End Sub
Public ReadOnly Property Account As CloudStorageAccount
Get
Return _Account
End Get
End Property
Public ReadOnly Property ImageContainerName As String
Get
Return _ImageContainerName
End Get
End Property
Public Function GetImageFromStore(ByVal imageKey As String) As IO.Stream
Dim blobStorage As CloudBlobClient = _Account.CreateCloudBlobClient
Dim container As CloudBlobContainer = blobStorage.GetContainerReference(Me.ImageContainerName)
If Not container.Exists Then
container.CreateIfNotExists()
container.SetPermissions(New BlobContainerPermissions With {.PublicAccess = BlobContainerPublicAccessType.Off})
End If
Dim blob As CloudBlockBlob = container.GetBlockBlobReference(imageKey)
Dim stream As New MemoryStream()
'Added 11/21/2012 because the pages were erroring out when the image wasn't found in the blob.
If blob.Exists Then
blob.DownloadToStream(stream)
stream.Position = 0
End If
Return stream
End Function
错误出现在这一行:
DIm blobStorage As CloudBlobClient = _Account.CreateCloudBlobClient
【问题讨论】:
-
尝试导入 Microsoft.WindowsAzure.StorageClient
-
您使用的是哪个 Azure.NET SDK 和 Azure Storage nuget 版本?
-
尝试使用客户端,它不允许检查文件是否存在并且它没有以可用格式返回文件。
-
Azure SDK 是 AzureSDK2.2DLLs 版本 1.0.0 WindowsAzure.Storage 是 V8.3.0。
标签: asp.net vb.net azure azure-storage