我遇到以下错误
在未引用的程序集中定义了类型'ServiceStack.Common.Web.EndPoint'。您必须添加对程序集'ServiceStack.Common,Version = 3.9.70.0,Culture = neutral,PublicKeyToken = e33b67d3bb5581e4'的引用。
我已经安装了错误中指定的版本,但是仍然出现错误。它也给出了与程序集签名有关的错误,但是当我尝试安装签名版的nugget软件包时,它与我的.Net代码版本不兼容。
公共TescoDirectIdentityAuthorization getTescoDirectAuthToken(字符串clubcard,字符串邮政编码,字符串姓氏) { 字典存储的访问令牌= TescoDirectIdentityAuthorization.getInstance(); ICacheProvider cacheProvider = new RedisCacheProvider();
clubcard = "634004027555269583";
postcode = "AL7 3EQ";
surname = "Order";
if (!cacheProvider.IsInCache(clubcard))
{
Dictionary<string, string> header = new Dictionary<string, string>();
IRestApiCommand command = new RestApiCommandFactory().GetApiCommand();
string proxyurl = SecurityFeatureHelper.GetJuvoConfigValue("CoApiProxy", "JuvoDeploymentConfig");
string IdentifyUrl = SecurityFeatureHelper.GetJuvoConfigValue("TescoDirectIdentityServiceUrl", "JuvoDeploymentConfig");
IdentityAuthorization IdentityAuthToken = IdentityAuthorization.getInstance();
try
{
//Set Header from this authorization token for second call
header = new Dictionary<string, string>();
try
{
IdentityAuthToken = getAuthToken();
if (IdentityAuthToken != null && !string.IsNullOrEmpty(IdentityAuthToken.AuthorizationToken))
{
string bearer = SecurityFeatureHelper.GetJuvoConfigValue("TescoDirectApiBearer", "JuvoDeploymentConfig");
if (!string.IsNullOrEmpty(bearer))
{
header.Add("Authorization", bearer + " " + IdentityAuthToken.AuthorizationToken);
}
else
{
header.Add("Authorization", IdentityAuthToken.AuthorizationToken);
}
}
}
catch (Exception ex)
{
LoggingHelper.LogErrorEvent(EventLogName.Tesco, EventSource.TescoCSA, "getTescoDirectAuthToken() method error while trying to fetch identity token:" + ex.Message);
throw ex;
}
//header.Add("Content-Type", "application/json");
//header.Add("Content-Type", "application/json; charset=utf-8");
TescoDirectIdentityTokenRequest req = new TescoDirectIdentityTokenRequest();
req.clubcard = clubcard;
req.postcode = postcode;
req.surname = surname;
Dictionary<string, string> postData = new Dictionary<string, string>()
{
{"", JavascriptUtility.Serialize(req)}
};
command = new RestApiCommandFactory().GetApiCommand();
callstart = DateTime.Now;
TescoDirectIdentityAPITokenResponse response = command.Execute<TescoDirectIdentityAPITokenResponse>(IdentifyUrl, null, postData, "POST", "application/json", "JSON", header, proxyurl);
callend = DateTime.Now;
bool val = LoggingHelper.GetTimeDiff(callstart, callend);
if (val)
{
LoggingHelper.LogInformationEvent(EventLogName.Tesco, EventSource.TescoCSA, "Logging for getTescoDirectAuthToken,time taken :" + (callend - callstart).TotalSeconds);
}
if (!String.IsNullOrEmpty(response.error))
{
Exception ex = new Exception("Error:" + response.error + " Description:" + response.description);
throw ex;
}
TescoDirectIdentityAuthorization TescoDirectIdentityAuthToken = new TescoDirectIdentityAuthorization();
//Set Values to Identitiy Authorize Token
TescoDirectIdentityAuthToken.AuthorizationToken = response.access_token;
TescoDirectIdentityAuthToken.CreatedTime = DateTime.Now;
TescoDirectIdentityAuthToken.ExpiryTime = IdentityAuthToken.CreatedTime.AddSeconds(response.expires_in - 120);
TescoDirectIdentityAuthToken.RefreshToken = response.refresh_token;
TescoDirectIdentityAuthToken.LastValidityChecked = DateTime.Now;
if (response.Claims != null & response.Claims.Length > 0)
{
foreach (IdentityDirectServiceClaims claim in response.Claims)
{
switch (claim.claimType.Substring(claim.claimType.LastIndexOf("/") + 1).ToLower().Trim())
{
case "userkey":
{
TescoDirectIdentityAuthToken.UserKey = claim.value;
break;
}
default:
break;
}
}
}
cacheProvider.Set<TescoDirectIdentityAuthorization>(clubcard, TescoDirectIdentityAuthToken, new TimeSpan(0, 0, response.expires_in - 120));
return TescoDirectIdentityAuthToken;
}
catch (Exception ex)
{
LoggingHelper.LogErrorEvent(EventLogName.Tesco, EventSource.TescoCSA, "Tesco Direct IdentityService:" + ex.Message);
throw ex;
}
}
else
{
return cacheProvider.Get<TescoDirectIdentityAuthorization>(clubcard);
}
}