我正在嘗試從我的 Xamarin 應用程式向我的 Azure blob(圖片)添加元資料。我首先在 C# 控制臺應用程式中嘗試了這個并且它作業了,但是當我嘗試將代碼放入我的 Xamarin 應用程式(作為一個新的獨立類)時,我收到以下錯誤。
CS8370 功能“異步流”在 C# 7.3 中不可用。請使用 8.0 或更高版本的語言。
錯誤指向第一個 await (await foreach (BlobItem ...)。我使用的是 netstandard 2.0(在我的 .csproj 檔案中它說 <TargetFramework>netstandard2.0</TargetFramework>)
我想知道我是否可以更改我的代碼/更改任何設定以使其作業?
這是我的代碼:
static async Task AddType()
{
string connectionString = "xxx";
// Create a BlobServiceClient object which will be used to create a container client
BlobServiceClient blobServiceClient = new BlobServiceClient(connectionString);
// Get the container client object
BlobContainerClient containerClient = blobServiceClient.GetBlobContainerClient("raspberryuploads");
// List all blobs in the container
await foreach (BlobItem blobItem in containerClient.GetBlobsAsync())
{
BlobClient blobClient = new BlobClient("xxx", "yyy", blobItem.Name);
IDictionary<string, string> metadata = new Dictionary<string, string>();
// Add metadata to the dictionary by using key/value syntax
metadata["Type"] = "Result";
// Set the blob's metadata.
await blobClient.SetMetadataAsync(metadata);
}
}
這段代碼主要由微軟檔案組成。
鏈接:Blob 元資料
uj5u.com熱心網友回復:
該錯誤訊息意味著您嘗試使用的 C# 功能不屬于您當前使用的版本。您使用的是 .NET Standard 2.0 附帶的 C# 7.3。但是您需要 .NET Standard 2.1 附帶的 C# 8。您可以在此處閱讀有關它的更多資訊https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/configure-language-version和此處https://docs.microsoft.com/en-us/ dotnet/csharp/whats-new/csharp-8。嘗試將您的 .NET Standard 版本升級到 2.1,它應該可以運行。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/370995.html
