【发布时间】:2019-12-11 07:09:23
【问题描述】:
当我在天蓝色存储容器上应用方法 GetBlockBlobReference() 时出现以下错误。我可以使用Microsoft.WindowsAzure.Storage NuGet 获取这个容器,当我导航到这个 Nuget 时我也可以看到所有方法,但是在编译时找不到一些方法。
System.Private.CoreLib:执行函数时出现异常: 富裕功能。 GoogleAnalytics:找不到方法:'无效 Microsoft.WindowsAzure.Storage.Blob.CloudBlockBlob.UploadFromStream(System.IO.Stream, Microsoft.WindowsAzure.Storage.AccessCondition, Microsoft.WindowsAzure.Storage.Blob.BlobRequestOptions, Microsoft.WindowsAzure.Storage.OperationContext)'
在互联网上,每个人都说“降级”Azure Storage Nuget 版本,但无法正常工作。我尝试过版本 5、6、7 甚至 9。我使用 .NET Framework 4.7 作为类库,由版本 2 上的函数项目调用。
一些代码(我可以再次获取容器):
public void UploadFile( CloudBlobContainer container )
{
var filePathOnServer = Path.Combine("C:/temp/test/c.csv");
using (var fileStream = File.OpenRead(filePathOnServer))
{
var filename = "c.csv"; // Trim fully pathed filename to just the filename
var blockBlob = container.GetBlockBlobReference(filename);
blockBlob.UploadFromStream(fileStream);
}
}
我们在其他项目(其他版本的 .NET)上以相同的方式使用 Azure Blob 存储,它工作正常!
谢谢
【问题讨论】:
-
如果答案对你有用,请帮忙标记为答案,谢谢。
标签: c# visual-studio azure azure-storage