我有一个.Net Framework 4.7.2 Winforms应用程序,我试图从Azure存储帐户流式传输blob,但在.OpenRead()调用上出现错误“The type initializer for 'PerTypeValues`1'”。我可以正常上传。
Public Function StreamFileFromAzureStorageAcct(ByVal clientLocalFilePath As String, ByVal containerDestName As String, ByRef strReturn As String) As StreamReader
Dim strReturn As String = String.Empty
Dim textInStream As Stream = Nothing
Dim textIn As StreamReader = Nothing
Dim connectionString As String = Nothing
Try
connectionString = String.Format("DefaultEndpointsProtocol=https;AccountName={0};AccountKey={1};EndpointSuffix={2}", modConfigSettings.AzureStorageAcctName, modConfigSettings.AzureStorageAcctKey, modConfigSettings.AzureStorageAcctURL)
Dim Container As BlobContainerClient = New BlobContainerClient(connectionString, containerDestName)
Dim BlobClient As BlobClient = Container.GetBlobClient(Path.GetFileName(clientLocalFilePath))
Dim readOptions As BlobOpenReadOptions = New BlobOpenReadOptions(False)
readOptions.Position = 0
''Azure Storage Acct Read call returns a Stream
textInStream = BlobClient.OpenRead(readOptions)
'' Pass the Stream to a StreamReader to stay inline with existing code.
textIn = New StreamReader(textInStream)
strReturn = "Success"
Return textIn
Catch er As Exception
strReturn = String.Format("Failed to Stream from Storage Account: {0}-File:{1}-connectionString: {2}-{3}", er.Message, Path.GetFileName(clientLocalFilePath), connectionString, er.StackTrace)
End Try
Return Nothing
End Function
字符串
无法从存储帐户流式传输:“PerTypeValues”1“的类型初始值设定项引发异常。- at System.SpanHelpers.IsReferenceOrContainsReferencesT at Azure.Storage. Blobs. BlobRestClient. Get_ResponseClassifier200()at Azure.Storage.Blobs.BlobRestClient. GetPropertyRequest(String snapshot,String versionId,Nullable1 timeout,String leaseId,String transitionKey,String transitionKeySha256,StringtransitionAlgorithm,String ifTags,RequestConditions requestConditions,RequestContext context)位于Azure.Storage.Blobs.BlobRestClient.GetProperties(String snapshot,String versionId,Nullable1 timeout,String leaseId,String transitionKey,String transitionKeySha256,String transitionAlgorithm,String ifTags,RequestConditions requestConditions,RequestContext context)位于Azure.Blobs.Specialized.BlobBaseClient.d__124.MoveNext()-从抛出异常的上一个位置开始的堆栈跟踪结束-位于System. System. Blobs. Specialized. Blobs. Services.TaskAwaiter.ThrowForNonSuccess(任务任务)atSystem. token. token服务.任务等待.处理非同步和同步通知(任务任务)atAzure.Blob.Blobs.Specialized.BlobBaseClient.d__98.MoveNext()-从引发异常的上一个位置开始的堆栈跟踪结束- atSystem. System. Blobs. Service.TaskAwaiter.ThrowForNonSuccess(任务任务)位于System. System. Data. DataServices.TaskAwaiter. HandleNoncalling和NoncallinggerNotification(任务任务)atAzure.Storage.Blobs.Specialized.BlobBaseClient.OpenRead(BlobOpenReadOptions选项,CancellationToken cancellationToken)在DBSLOCKObjects.RemFredDataAdmin. StreamFileFromAzured帐户(StringclientLocalFilePath,String containerDestName,String& strReturn)在C:\Users\csale\source\Workspaces\Application Server\FredServer\DBSLOCKObjects\RemFredDataAdmin.vb:行15904
1条答案
按热度按时间sczxawaw1#
Azure Manager.vb:
字符串
型
的数据
Azure存储中blob的内容如下所示。
的