简体   繁体   中英

An unhandled exception of type 'System.StackOverflowException' occurred in Microsoft.WindowsAzure.Storage.dll

I am presently working with windows 10 universal application, here i am working with azure storage.

I am getting above error when i downloading file file from windows azure storage.

Here is my download code:

private async Task<int> DownloadFromAzureStorage()
{
   try
     {
     //  create Azure Storage
     CloudStorageAccount storageAccount = CloudStorageAccount.Parse("DefaultEndpointsProtocol=https;AccountName=<myaccname>;AccountKey=<mykey>");

     //  create a blob client.
     CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();

     //  create a container 
     CloudBlobContainer container = blobClient.GetContainerReference("sample");

     await container.CreateIfNotExistsAsync();

    //  create a block blob
    CloudBlockBlob blockBlob = container.GetBlockBlobReference("abc.jpg");

    FileSavePicker openPicker = new FileSavePicker();
    openPicker.SuggestedStartLocation = PickerLocationId.PicturesLibrary;
    openPicker.FileTypeChoices.Add("File", new List<string>() { ".jpg" });
    openPicker.SuggestedFileName = "New Documents";
    var imgFile = await openPicker.PickSaveFileAsync();

    await blockBlob.DownloadToFileAsync(imgFile); **//Error occuring in this line**
    return 1;
    }
    catch
     {
       //  return error
       return 0;
     }
   }

File Uploading to my azure storage is success, but when i download to my uploaded my it showing the error is "An unhandled exception of type 'System.StackOverflowException' occurred in Microsoft.WindowsAzure.Storage.dll" in await blockBlob.DownloadToFileAsync(imgFile); Line

please help me to resolve this issue..

This is a known issue with the DownloadToFileAsync() method in the Win10 Universal Storage Client (unfortunately). The bug is fixed in the current preview release (7.0.2-preview), and will be fixed in an upcoming non-preview release. To fix your issue for now, please change your DownloadToFile call to the following:

await blockBlob.DownloadToFileAsync(imgFile, null, null, null, CancellationToken.None);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM