[英]Extension Method usage in .NET Core 2.0?
我正在嘗試使用Microsoft.Azure.Management.Compute ComputeManagementClient Usage
屬性來列出通過Azure的所有資源使用情況。
我專門使用Usage.ListAsync()
實現此目的。 根據文檔,這是一種擴展方法。
我使用以下方法創建ComputeManagementClient實例后,調用擴展方法:
public async Task<IComputeUsage> GetResourceUsage(int customerId)
{
var azureClient = _dbContext.CreateAzureComputeClient(customerId);
var usageReport = await azureClient.Usage.ListAsync();
}
但是,這將返回以下錯誤:
'IUsageOperations' does not contain a definition for Listasync and the best extention method overload ProvidersOptionsExtensions.ListAsync... Requires a receiver of type 'IProvidersOperations'
。
這是一個錯誤,還是我錯誤地調用了該方法?
編輯:我在我的代碼中使用正確的名稱空間:
using System.Threading.Tasks;
using Microsoft.Azure.Management.Compute;
using Microsoft.Azure.Management.ResourceManager.Fluent;
using Microsoft.Azure.Management.Compute.Fluent;
但是,VS2017並未指出名稱空間的使用情況(灰色,然后是黑色)。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.