C# 无法将带[]的索引应用于类型为';System.Collections.Specialized.NameValueCollection';
我已经尝试了所有方法来访问AppSettings,但我无法让它正常工作 我有一个类库,需要访问web应用程序设置。我查过了,没有 “System.Collections.Specialized.NameValueCollection”导入 有人有什么想法吗C# 无法将带[]的索引应用于类型为';System.Collections.Specialized.NameValueCollection';,c#,.net,collections,configuration,C#,.net,Collections,Configuration,我已经尝试了所有方法来访问AppSettings,但我无法让它正常工作 我有一个类库,需要访问web应用程序设置。我查过了,没有 “System.Collections.Specialized.NameValueCollection”导入 有人有什么想法吗 using System; using System.Collections.Generic; using System.Configuration; using System.Linq; using System.Net.Http; usi
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using System.Web;
using System.Web.Configuration;
public static class httpresponsebase_setoauthfromcookie
{
public static void SetOauthFromCookie(this HttpResponseBase response, string verify,
string token, string tokenSecret,
string userName,
bool isTwitter)
{
string pas = WebConfigurationManager.AppSettings["cryptpass"],
crypt = ((verify.Length > 3 ? (verify + ":") : "twit") + token + ":" + tokenSecret).Encrypt(pas);
//
var cookie = new HttpCookie(userName + (isTwitter ? "twitter" : "linkedin"), HttpServerUtility.UrlTokenEncode(Convert.FromBase64String(crypt)));
cookie.Expires = DateTime.Now.AddDays(1);
response.Cookies.Add(cookie);
}}
我添加了对System 4.0的引用,并修复了所有问题。验证您的项目不是根据客户端配置文件框架编译的。此外,发布真实代码而不是代码的屏幕截图会使阅读所有相关部分变得非常困难。该库是根据4.5框架而不是客户端配置文件编译的。类似于这还不够。我在类库中工作,无法导入“System.Collections.Specialized.NameValueCollection”。我只有System 2.0。我怎样才能解决这个问题??