异步流在 xamarin (C# 7.3) 中不可用
async streams not available in xamarin (C# 7.3)
我正在尝试从我的 Xamarin 应用程序向我的 Azure blob(图片)添加元数据。我首先在 C# 控制台应用程序中尝试了这个并且它有效,但是当我尝试将代码放入我的 Xamarin 应用程序(作为一个新的,单独的 class)时,我收到以下错误。
CS8370 Feature 'async streams' is not available in C# 7.3. Please use language version 8.0 or greater.
错误指向第一个 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);
}
}
此代码主要来自微软文档。
该错误消息表示您尝试使用的 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 and here https://docs.microsoft.com/en-us/dotnet/csharp/whats-new/csharp-8。
尝试将您的 .NET Standard 版本升级到 2.1,它应该 运行.
我正在尝试从我的 Xamarin 应用程序向我的 Azure blob(图片)添加元数据。我首先在 C# 控制台应用程序中尝试了这个并且它有效,但是当我尝试将代码放入我的 Xamarin 应用程序(作为一个新的,单独的 class)时,我收到以下错误。
CS8370 Feature 'async streams' is not available in C# 7.3. Please use language version 8.0 or greater.
错误指向第一个 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);
}
}
此代码主要来自微软文档。
该错误消息表示您尝试使用的 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 and here https://docs.microsoft.com/en-us/dotnet/csharp/whats-new/csharp-8。 尝试将您的 .NET Standard 版本升级到 2.1,它应该 运行.