Error: The type or namespace name 'Configuration' does not exist in the namespace 'System.Web'

Error: The type or namespace name 'Configuration' does not exist in the namespace 'System.Web'

我正在尝试使用来自 https://docs.microsoft.com/en-us/azure/key-vault/key-vault-use-from-web-application

的以下代码
//add these using statements
using Microsoft.IdentityModel.Clients.ActiveDirectory;
using System.Threading.Tasks;
using System.Web.Configuration;

//this is an optional property to hold the secret after it is retrieved
public static string EncryptSecret { get; set; }

//the method that will be provided to the KeyVaultClient
public static async Task<string> GetToken(string authority, string resource, string scope)
{
    var authContext = new AuthenticationContext(authority);
    ClientCredential clientCred = new ClientCredential(WebConfigurationManager.AppSettings["ClientId"],
            WebConfigurationManager.AppSettings["ClientSecret"]);
    AuthenticationResult result = await authContext.AcquireTokenAsync(resource, clientCred);

    if (result == null)
        throw new InvalidOperationException("Failed to obtain the JWT token");

    return result.AccessToken;
}

我试图将上面的代码添加到 c# class 库中的 class 中,为了修复错误,我尝试了以下线程中的答案:https://forums.asp.net/t/1205345.aspx?The+type+or+namespace+name+Configuration+does+not+exist+in+the+namespace+System+Web+.建议的答案是:您需要通过 "Add Reference" 对话框添加 System.Configuration DLL。右键单击引用和 select 添加引用,然后在 .NET 选项卡下 select System.Configuration。

但是,当我尝试添加 System.Configuration DLL 作为参考时,我没有在列表中看到它。

我在哪里可以找到这个 System.Configuration DLL?

==================更新======================

添加程序集相关的屏幕截图。没有添加 System.Configuration 程序集的选项:

原 post 的两位评论者都是正确的。我只是在这里总结一下答案:

  1. 我需要创建 .NET Framework class 库,而不是 .NET Standard class 库,因为 WebConfigurationManager 仅适用于 .NET Framework。

  2. 右键单击 class 库的引用 -> 添加引用 -> 程序集 -> 找到 System.Web.dllSystem.Configuration.dll -> 确定。

不再有错误!