C# 将文件上载到blob存储错误get\u NetworkTimeout没有实现
我试图调用TransferManager.UploadAsync,但始终出现以下错误:C# 将文件上载到blob存储错误get\u NetworkTimeout没有实现,c#,azure,.net-4.6.1,C#,Azure,.net 4.6.1,我试图调用TransferManager.UploadAsync,但始终出现以下错误: Method 'get_NetworkTimeout' in type 'Microsoft.Azure.Storage.File.FileRequestOptions' from assembly 'Microsoft.Azure.Storage.File, Version=11.1.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' does no
Method 'get_NetworkTimeout' in type 'Microsoft.Azure.Storage.File.FileRequestOptions' from assembly 'Microsoft.Azure.Storage.File, Version=11.1.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' does not have an implementation.
这是我在BaseBlobRepository.cs中的方法:
此问题已在最新版本中解决。将Azure软件包升级到11.1.7
在我的例子中,当我安装NuGet软件包Microsoft.Azure.Storage.Common v11.1.7但忘记安装Microsoft.Azure.Storage.Blob时发生了这种情况可能是因为您传递了null,因为它可能从GAC获得旧版本的dll,因此出现了错误。因此,在您的项目中添加对Microsoft.Azure.Storage.File的引用,错误应该得到解决。即使使用最新版本,我也会收到此错误!
public void Add(string name, System.IO.Stream fileStream, string contentType = null)
{
TransferManager.Configurations.ParallelOperations = 64;
SingleTransferContext context = new SingleTransferContext();
context.ProgressHandler = new Progress<TransferStatus>((progress) =>
{
Console.WriteLine("Bytes uploaded: {0}", progress.BytesTransferred);
});
var container = GetBlobContainer(_containerName);
CloudBlockBlob blockBlob = container.GetBlockBlobReference(name);
if (contentType != null)
{
blockBlob.Properties.ContentType = contentType;
}
var task = TransferManager.UploadAsync(
fileStream, blockBlob, null, context, CancellationToken.None);
task.Wait();
}