我尝试使用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#类库中的类中,为了修复错误,我在下面的线程中尝试了答案:https://forums.asp.net/t/1205345.aspx?The+type+or+namespace+name+Configuration+does+not+exist+in+the+namespace+System+Web+。建议的答案是:您需要通过&#34; Add Reference&#34;添加System.Configuration DLL。对话框。右键单击References并选择Add Reference,然后在.NET选项卡下选择System.Configuration。
但是,当我尝试添加System.Configuration DLL作为参考时,我在列表中看不到它。
我在哪里可以找到这个System.Configuration DLL?
==================更新======================