Azure / azure-sdk-for-net

This repository is for active development of the Azure SDK for .NET. For consumers of the SDK we recommend visiting our public developer docs at https://learn.microsoft.com/dotnet/azure/ or our versioned developer docs at https://azure.github.io/azure-sdk-for-net.
MIT License
5.47k stars 4.8k forks source link

[BUG] System.MissingMethodException: Method not found: System.ReadOnlyMemory`1<byte> Azure.Storage.UploadTransferValidationOptions.get_PrecalculatedChecksum() when trying to upload file #32474

Open mlxyz opened 1 year ago

mlxyz commented 1 year ago

Library name and version

Azure.Storage.Blobs 12.14.1

Describe the bug

When trying to upload a simple file using await container.GetBlobClient(file).UploadAsync(Path.Combine(Constants.FileStoragePath, file)) under Xamarin.Forms 5 targeting .NET Standard 2.1 a MissingMethodException is thrown with this stack trace:

Error during sync: "System.MissingMethodException: Method not found: System.ReadOnlyMemory`1<byte> Azure.Storage.UploadTransferValidationOptions.get_PrecalculatedChecksum()
  at Azure.Storage.Blobs.Specialized.BlockBlobClient.GetPartitionedUploader (Azure.Storage.StorageTransferOptions transferOptions, Azure.Storage.UploadTransferValidationOptions validationOptions, System.Buffers.ArrayPool`1[T] arrayPool, System.String operationName) [0x00006] in <7f170a8e252647f1bcb807347ee9b683>:0 
  at Azure.Storage.Blobs.BlobClient.GetPartitionedUploader (Azure.Storage.StorageTransferOptions transferOptions, Azure.Storage.UploadTransferValidationOptions validationOptions, System.Buffers.ArrayPool`1[T] arrayPool, System.String operationName) [0x00006] in <7f170a8e252647f1bcb807347ee9b683>:0 
  at Azure.Storage.Blobs.BlobClient.StagedUploadInternal (System.IO.Stream content, Azure.Storage.Blobs.Models.BlobUploadOptions options, Sys
tem.Boolean async, System.Threading.CancellationToken cancellationToken) [0x00194] in <7f170a8e252647f1bcb807347ee9b683>:0 
  at Azure.Storage.Blobs.BlobClient.UploadAsync (System.String path, Azure.Storage.Blobs.Models.BlobHttpHeaders httpHeaders, System.Collections.Generic.IDictionary`2[TKey,TValue] metadata, Azure.Storage.Blobs.Models.BlobRequestConditions conditions, System.IProgress`1[T] progressHandler, System.Nullable`1[T] accessTier, Azure.Storage.StorageTransferOptions transferOptions, System.Threading.CancellationToken cancellationToken) [0x000e0] in <7f170a8e252647f1bcb807347ee9b683>:0 
  at Azure.Storage.Blobs.BlobClient.UploadAsync (System.String path, System.Boolean overwrite, System.Threading.CancellationToken cancellationToken) [0x000bb] in <7f170a8e252647f1bcb807347ee9b683>:0 
  at Azure.Storage.Blobs.BlobClient.UploadAsync (System.String path, System.Threading.CancellationToken cancellationToken) [0x00079] in <7f170a8e252647f1bcb807347ee9b683>:0 
  at Azure.Storage.Blobs.BlobClient.UploadAsy
nc (System.String path) [0x00077] in <7f170a8e252647f1bcb807347ee9b683>:0 
  at NegamiApp.Services.Storage.DatabaseSynchronizationService.SyncFilesAsync () [0x007be] in C:\Users\...\DatabaseSynchronizationService.cs:213 
  at NegamiApp.Services.Storage.DatabaseSynchronizationService.SyncAsync () [0x0015b] in C:\Users\...\DatabaseSynchronizationService.cs:132"

Downloading files from the container is working fine. I think the upload worked with with version 12.10.0

Expected behavior

The file is uploaded without any exceptions.

Actual behavior

The above mentioned exception is thrown and the file is not uploaded.

Reproduction Steps

Try to upload a file using

await container.GetBlobClient(file).UploadAsync(Path.Combine(Constants.FileStoragePath, file))

in the environment described below.

Environment

Microsoft Visual Studio Professional 2022 Version 17.3.5 VisualStudio.17.Release/17.3.5+32922.545 Microsoft .NET Framework Version 4.8.09032

Xamarin.Forms 5.0.0.2515 targeting .NET Standard 2.1 (C# lang version 8.0) Tested on iPad Mini Simulator & iPad Pro physical device

ghost commented 1 year ago

Thank you for your feedback. This has been routed to the support team for assistance.

navba-MSFT commented 1 year ago

@mlxyz Apologies for the late reply. Thanks for reaching out to us and reporting this issue. We are looking into this issue and we will provide an update.

navba-MSFT commented 1 year ago

@mlxyz I tried to use the Azure.Storage.Blobs version 12.14.1.0 library and the below code within my sample application and it worked fine. I am unable to reproduce this error.

            string localFilePath = @"C:\fileName.txt";
            string fileName = Path.GetFileName(localFilePath);
            await container.GetBlobClient(fileName).UploadAsync(localFilePath, true);

Could you please confirm if the issue occurs only within Xamarin.Forms 5 targeting .NET Standard 2.1 application ? Awaiting your reply.

mlxyz commented 1 year ago

Thanks for looking into this @navba-MSFT. I've just tried running your code in a unit test project (targeting .NET Core 3.1) and it worked as expected. Maybe the issue also has something to do with the iOS platform? I will try out more next week!

navba-MSFT commented 1 year ago

@mlxyz Thanks for getting back. I was testing this on Windows platform. If you see the same issue on iOS platform using my above sample code, please do let me know.

PS: Update the local path of the file in the sample before testing the sample.

ghost commented 1 year ago

Hi @mlxyz. Thank you for opening this issue and giving us the opportunity to assist. We believe that this has been addressed. If you feel that further discussion is needed, please add a comment with the text “/unresolve” to remove the “issue-addressed” label and continue the conversation.

mlxyz commented 1 year ago

Hi @navba-MSFT, I can now confirm that this issue is happening on iOS, but not on Windows /unresolve I've created an MRE project here: https://github.com/mlxyz/32474-blob-storage-ios-repro I've tested this exact project on an iPad Pro (6th Generation) simulator with ipadOS 16.1 and it consistently fails with the exception I described above: grafik

navba-MSFT commented 1 year ago

@mlxyz Thanks for getting back. We will check this and get back to you. In the meantime, Could you please let us know if you have tried to isolate the issue by changing the file size and file location etc ? Awaiting your reply.

mlxyz commented 1 year ago

@navba-MSFT Yes, I've tried image files and text files of various sizes (including very small ones, couple of bytes) in different locations (Path.GetTempFileName or under Environment.SpecialFolder.LocalApplicationData) - all leads to the same exception.

navba-MSFT commented 1 year ago

@mlxyz Apologies for the late reply. Thanks for getting back. I am discussing this issue internally. I will update this thread once I have more details.

navba-MSFT commented 1 year ago

@mlxyz It seems .NET has failed to load a type into the runtime. ReadOnlyMemory is a .NET type from the System.Memory package. Could you please check if you can include this package from the nuget and see if that helps ?

mlxyz commented 1 year ago

Hi @navba-MSFT, thanks for getting back. I just checked and the packages System.Memory (4.5.5) and System.Memory.Data (7.0.0) were already installed (also in the repro project I linked above) but the problem still persists. So this doesn't seem to be the problem.

ghost commented 1 year ago

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @xgithubtriage.

Issue Details
### Library name and version Azure.Storage.Blobs 12.14.1 ### Describe the bug When trying to upload a simple file using `await container.GetBlobClient(file).UploadAsync(Path.Combine(Constants.FileStoragePath, file))` under Xamarin.Forms 5 targeting .NET Standard 2.1 a `MissingMethodException` is thrown with this stack trace: ``` Error during sync: "System.MissingMethodException: Method not found: System.ReadOnlyMemory`1 Azure.Storage.UploadTransferValidationOptions.get_PrecalculatedChecksum() at Azure.Storage.Blobs.Specialized.BlockBlobClient.GetPartitionedUploader (Azure.Storage.StorageTransferOptions transferOptions, Azure.Storage.UploadTransferValidationOptions validationOptions, System.Buffers.ArrayPool`1[T] arrayPool, System.String operationName) [0x00006] in <7f170a8e252647f1bcb807347ee9b683>:0 at Azure.Storage.Blobs.BlobClient.GetPartitionedUploader (Azure.Storage.StorageTransferOptions transferOptions, Azure.Storage.UploadTransferValidationOptions validationOptions, System.Buffers.ArrayPool`1[T] arrayPool, System.String operationName) [0x00006] in <7f170a8e252647f1bcb807347ee9b683>:0 at Azure.Storage.Blobs.BlobClient.StagedUploadInternal (System.IO.Stream content, Azure.Storage.Blobs.Models.BlobUploadOptions options, Sys tem.Boolean async, System.Threading.CancellationToken cancellationToken) [0x00194] in <7f170a8e252647f1bcb807347ee9b683>:0 at Azure.Storage.Blobs.BlobClient.UploadAsync (System.String path, Azure.Storage.Blobs.Models.BlobHttpHeaders httpHeaders, System.Collections.Generic.IDictionary`2[TKey,TValue] metadata, Azure.Storage.Blobs.Models.BlobRequestConditions conditions, System.IProgress`1[T] progressHandler, System.Nullable`1[T] accessTier, Azure.Storage.StorageTransferOptions transferOptions, System.Threading.CancellationToken cancellationToken) [0x000e0] in <7f170a8e252647f1bcb807347ee9b683>:0 at Azure.Storage.Blobs.BlobClient.UploadAsync (System.String path, System.Boolean overwrite, System.Threading.CancellationToken cancellationToken) [0x000bb] in <7f170a8e252647f1bcb807347ee9b683>:0 at Azure.Storage.Blobs.BlobClient.UploadAsync (System.String path, System.Threading.CancellationToken cancellationToken) [0x00079] in <7f170a8e252647f1bcb807347ee9b683>:0 at Azure.Storage.Blobs.BlobClient.UploadAsy nc (System.String path) [0x00077] in <7f170a8e252647f1bcb807347ee9b683>:0 at NegamiApp.Services.Storage.DatabaseSynchronizationService.SyncFilesAsync () [0x007be] in C:\Users\...\DatabaseSynchronizationService.cs:213 at NegamiApp.Services.Storage.DatabaseSynchronizationService.SyncAsync () [0x0015b] in C:\Users\...\DatabaseSynchronizationService.cs:132" ``` Downloading files from the container is working fine. I think the upload worked with with version 12.10.0 ### Expected behavior The file is uploaded without any exceptions. ### Actual behavior The above mentioned exception is thrown and the file is not uploaded. ### Reproduction Steps Try to upload a file using ```csharp await container.GetBlobClient(file).UploadAsync(Path.Combine(Constants.FileStoragePath, file)) ``` in the environment described below. ### Environment Microsoft Visual Studio Professional 2022 Version 17.3.5 VisualStudio.17.Release/17.3.5+32922.545 Microsoft .NET Framework Version 4.8.09032 Xamarin.Forms 5.0.0.2515 targeting .NET Standard 2.1 (C# lang version 8.0) Tested on iPad Mini Simulator & iPad Pro physical device
Author: mlxyz
Assignees: -
Labels: `Storage`, `Service Attention`, `Client`, `customer-reported`, `bug`, `needs-team-attention`
Milestone: -
navba-MSFT commented 1 year ago

@mlxyz Thanks for getting back. I am adding the Service Team to look into this.

@xgithubtriage Could you please look into this once you get a chance ? Thanks in advance.

burrowj commented 1 year ago

I'm getting the same issue as this for a device , debug build on ios using visual studio on windows machine

AlanHoiland commented 1 year ago

Hello - We are seeing the same issue uploading files from iOS. Is there any update on resolving this?

navba-MSFT commented 1 year ago

@burrowj @AlanHoiland Apologies for the late reply. Unfortunately, I don't have any update on this. This issue has been reported to the Product Owners and we are waiting to hear back.

CC: @amnguye @seanmcc-msft

amnguye commented 1 year ago

@burrowj @AlanHoiland what version of the Azure.Storage (The common storage package that the Azure.Storage.Blobs package takes a dependency on) are you using?

AlanHoiland commented 1 year ago

Azure.Storage.Blobs is 12.14.1 Azure.Storage.Common is 12.13.0

Both appear to be the latest, stable versions.

Thanks! Alan

burrowj commented 1 year ago

PackageReference Include="Azure.Storage.Blobs" Version="12.14.1"

Also, I have found that when i build this Visual Studio for Mac it works fine When i build with Visual Studio for windows i get this error

Thanks John

burrowj commented 1 year ago

Is there any news on this getting fixed? I have gone back to "Azure.Storage.Blobs" Version="12.13.0" and it works again I have a Xamarin Forms App I build on windows using Visual Studio and a Mac Host build machine for Ios

mroseberry99 commented 1 year ago

I have the same exact issue. It ONLY happens on iOS devices for Xamarin. I've created a new Xamarin App to remove all other factors. It works on Android fine. Also, this isn't the only method that seems to go missing on iOS devices. I'm upgrading from WindowsAzure.Storage to Azure.Storage.Blobs and ran into the following...

byte[] blobBytes = null;

StorageSharedKeyCredential cred = new StorageSharedKeyCredential("<username>", "<password>");
BlobServiceClient blobServiceClient = new BlobServiceClient(new Uri($"https://<StorageAccountName>.blob.core.windows.net"), cred, null);
BlobContainerClient containerClient = blobServiceClient.GetBlobContainerClient("<ContainerName>");

BlobClient blob = containerClient.GetBlobClient("<PathToBlob>");

using (MemoryStream ms = new MemoryStream())
{
    Response response = blob.DownloadTo(ms); //<-- Failing Here
    blobBytes = ms.ToArray();
}

only to get the runtime error Method not found: void Azure.Core.RequestUriBuilder.AppendPath(System.ReadOnlySpan`1,bool)

Again this code works everywhere(Android, windows) except on Xamarin.Forms app on iOS.

I sure hope this gets resolved soon as my whole app depends on the Azure Storage platform.

AlanHoiland commented 1 year ago

I have rolled back Azure.Storage.Blobs to 12.13.1 and it works on iOS. I just tried the latest stable version, 12.16.0, and it is still broken on iOS.

mroseberry99 commented 1 year ago

Yeah thanks a bunch AlanHoiland, I saw your post above and that worked for me too. Hopefully they can fix this problem soon for the newer versions.

zacllewis commented 1 year ago

Hi, I've also been using this package and have also come across this bug for iOS. I'm hoping this bug can be fixed soon, as we have currently reverted to version 12.13.1 as that still works.

janne-hmp commented 7 months ago

I'm using this package for a Xamarin.Forms app, and downgrading to 12.13.1 from 12.19.1 solved the issue on iOS. So I can confirm it persists until the latest stable version, making anything beyond 12.13.1 unusable on iOS. It would be great if this could be fixed for newer package versions.