我一直在研究这个我不断遇到的错误,但找不到正确的解决方案。好像对这个人来说是独一无二的。有谁知道我为什么会收到错误?非常感谢时间。
public void uploadPhoto(Stream photoStream, string photoName)
{
var credentials = new OAuthCredentials
{
Type = OAuthType.ProtectedResource,
SignatureMethod = OAuthSignatureMethod.HmacSha1,
ParameterHandling = OAuthParameterHandling.HttpAuthorizationHeader,
ConsumerKey = TwitterSettings.consumerKey,
ConsumerSecret = TwitterSettings.consumerKeySecret,
Token = TwitterSettings.accessToken,
TokenSecret = TwitterSettings.accessTokenSecret,
Version = "1.0a"
};
RestClient restClient = new RestClient
{
Authority = "https://upload.twitter.com",
HasElevatedPermissions = true,
Credentials = credentials,
Method = WebMethod.Post
};
RestRequest restRequest = new RestRequest
{
Path = "1/statuses/update_with_media.json"
};
restRequest.AddParameter("status", tbxNewTweet.Text);
restRequest.AddFile("media[]", photoName, photoStream, "image/jpg");
}
restClient.BeginRequest(restRequest, new RestCallback(PostTweetRequestCallback));
}
private void PostTweetRequestCallback(RestRequest request, Hammock.RestResponse response, object obj)
{
if (response.StatusCode == System.Net.HttpStatusCode.OK)
{
//Success code
}
}
我收到一个错误:
restClient.BeginRequest(restRequest, new RestCallback(PostTweetRequestCallback));
未处理 TypeLoadException 无法从程序集“mscorlib,版本=3.7.0.0,文化=中性,PublicKeyToken=969DB8053D3322AC”加载类型“System.Action”。