azure-sdk-for-net icon indicating copy to clipboard operation
azure-sdk-for-net copied to clipboard

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

Open mlxyz opened this issue 2 years ago • 21 comments

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

mlxyz avatar Nov 14 '22 23:11 mlxyz

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

ghost avatar Nov 15 '22 14:11 ghost

@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 avatar Dec 01 '22 03:12 navba-MSFT

@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.

navba-MSFT avatar Dec 01 '22 08:12 navba-MSFT

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!

mlxyz avatar Dec 02 '22 17:12 mlxyz

@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.

navba-MSFT avatar Dec 03 '22 04:12 navba-MSFT

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.

ghost avatar Dec 05 '22 03:12 ghost

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

mlxyz avatar Dec 07 '22 10:12 mlxyz

@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.

navba-MSFT avatar Dec 07 '22 10:12 navba-MSFT

@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.

mlxyz avatar Dec 07 '22 10:12 mlxyz

@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 avatar Dec 12 '22 07:12 navba-MSFT

@mlxyz It seems .NET has failed to load a type into the runtime. ReadOnlyMemory<T> 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 ?

navba-MSFT avatar Dec 15 '22 03:12 navba-MSFT

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.

mlxyz avatar Dec 15 '22 11:12 mlxyz

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<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

Author: mlxyz
Assignees: -
Labels:

Storage, Service Attention, Client, customer-reported, bug, needs-team-attention

Milestone: -

ghost avatar Dec 16 '22 03:12 ghost

@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.

navba-MSFT avatar Dec 16 '22 03:12 navba-MSFT

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

burrowj avatar Dec 20 '22 22:12 burrowj

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

AlanHoiland avatar Jan 12 '23 23:01 AlanHoiland

@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

navba-MSFT avatar Jan 13 '23 02:01 navba-MSFT

@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?

amnguye avatar Jan 13 '23 17:01 amnguye

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

Both appear to be the latest, stable versions.

Thanks! Alan

AlanHoiland avatar Jan 13 '23 17:01 AlanHoiland

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 avatar Jan 13 '23 20:01 burrowj

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

burrowj avatar Feb 15 '23 01:02 burrowj

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.

mroseberry99 avatar Apr 18 '23 20:04 mroseberry99

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.

AlanHoiland avatar Apr 24 '23 14:04 AlanHoiland

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.

mroseberry99 avatar Apr 24 '23 15:04 mroseberry99

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.

zacllewis avatar May 08 '23 09:05 zacllewis

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.

janne-hmp avatar Mar 16 '24 20:03 janne-hmp