我有一个 .NET Core 2.2 Web 应用程序,我正在尝试与我的 Azure 表存储资源进行通信。到目前为止我所拥有的:
using Microsoft.WindowsAzure.Storage;
using Microsoft.Azure.CosmosDB.Table;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace WebApplication1.Repositories
{
public class AssetRepository
{
public AssetRepository()
{
CloudStorageAccount storageAccount = CloudStorageAccount.Parse("cstring");
CloudTableClient tableClient = storageAccount.CreateCloudTableClient();
}
}
}
但是当我将鼠标悬停在 CreateCloudTableClient
上时我明白了Reference to type CloudStorageAccount claims it is defined in Microsoft.Azure.Storage.Common but it could not be found.
如何在 .NET Core 2.2 Web 应用中执行基本的表 CRUD?
最佳答案
您似乎混淆了新旧程序集。
using Microsoft.WindowsAzure.Storage;
using Microsoft.Azure.CosmosDB.Table;
可以使用对 Microsoft.Azure.CosmosDB.* 的较新 NuGet 引用,也可以使用较旧的 Microsoft.WindowsAzure.Storage 程序集,但不能同时使用两者。
例如:
using Microsoft.Azure.CosmosDB.Table; // replaces Microsoft.WindowsAzure.Storage.Table
using Microsoft.Azure.Storage; // replaces Microsoft.WindowsAzure.Storage
关于.net - CloudTableClient 与.NET Core 不兼容?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53803969/