在字典中找不到给定的键 [英] The given key was not found in the dictionary

查看:30
本文介绍了在字典中找不到给定的键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发 Windows Phone 8 应用程序.在这方面,我必须整合 Twitter.所以我遵循了下面的教程.

I'm developing windows phone 8 application. In this, I have to integrate Twitter. So I have followed the below tutorial.

http://code.msdn.microsoft.com/wpapps/Latest-Twitter-integration-a42e8bb6

我已经在我的应用程序中成功实现了 twitter.我也在模拟器和设备中对此进行了测试.一切都很好.

I've implemented successfully twitter in my application. I've tested this in Emulator and in device also. Everything was fine.

**突然在设备中应用程序无法打开推特登录页面.我在以下方法中以 开头的行中出现错误.

**Suddenly in the device the application is unable to open the twitter log in page. I'm getting the error in the below method at line started with .

 void requestTokenQuery_QueryResponse(object sender, WebQueryResponseEventArgs e)
    {
        try
        {
            StreamReader reader = new StreamReader(e.Response);
            string strResponse = reader.ReadToEnd();
            var parameters = MainUtil.GetQueryParameters(strResponse);
            **OAuthTokenKey = parameters["oauth_token"];**
            tokenSecret = parameters["oauth_token_secret"];
            var authorizeUrl = AppSettings.AuthorizeUri + "?oauth_token=" + OAuthTokenKey;

            Dispatcher.BeginInvoke(() =>
            {
                this.loginBrowserControl.Navigate(new Uri(authorizeUrl, UriKind.RelativeOrAbsolute));
            });
        }
        catch (Exception ex)
        {
            Dispatcher.BeginInvoke(() =>
            {
                MessageBox.Show(ex.Message);
                pi.IsVisible = false;
            });                
        }
    }

字典中不存在给定的键.

但在模拟器中,如果用户未登录并发布消息,我已成功重定向到登录页面.

But in Emulator I'm successfully redirected to log in page if user is not logged in and posting the message.

我不知道设备有什么问题.

I don't know what is the problem in the device.

推荐答案

当您用于测试应用程序的设备没有 simcard 时会出现此问题,因为没有 simcard 的设备无法匹配 twitter api 的时间服务器和这种不匹配会导致身份验证错误,对于 api,由于 api 服务器和设备之间的时间差异很大,凭据无效,因此请尝试在内置 simcard 的设备上检查它.

This issue occurs when the the device you are using for testing the app is without simcard, as it the device without the simcard cannot match the timings of the twitter api server and this mismatch causes the authentication error, as for the api the credentials are invalid due to heavy difference in the timings between api server and device, hence try checking it on a device that has a simcard inside.

这篇关于在字典中找不到给定的键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆