【发布时间】:2013-08-12 18:33:28
【问题描述】:
我已经尝试了所有方法来访问 AppSettings,但我无法让它工作。
我有一个需要访问网络 AppSettings 的类库。我查过了,没有 'System.Collections.Specialized.NameValueCollection' 导入。
有人有什么想法吗?
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);
}}
【问题讨论】:
-
验证您的项目没有针对客户端配置文件框架进行编译。
-
同时发布真实代码,而不是代码的屏幕截图,这使得阅读所有相关部分变得非常困难
-
库是根据 4.5 框架而不是客户端配置文件编译的。
-
这还不算。我在类库中工作,并且“System.Collections.Specialized.NameValueCollection”无法导入。
标签: c# .net collections configuration