Hi Prabir, I'm opening the issue per your request in this discussion:
http://facebooksdk.codeplex.com/discussions/284103
It seems like every time I try to login I get a KeyNotFoundException. It's rendering the application unusable since there's no graceful way out of this exception, at least none that I know. Thank you for your quick response!
comments from the discussion thread:
johnwarns
Sat at 2:16 PM
any one else getting a KeyNotFoundException error when running the Windows phone sample?
john
Reply
Reply with quote
Bob_12345
Today at 10:14 PM
I just started having this issue recently, out of the blue. The following exception occurs:
System.Collections.Generic.KeyNotFoundException was unhandled
Message=KeyNotFoundException
StackTrace:
at System.ThrowHelper.ThrowKeyNotFoundException()
at System.Collections.Generic.Dictionary`2.get_Item(String key)
at Facebook.JsonObject.get_Item(String key)
at Facebook.FacebookOAuthClient.BuildExchangeCodeForAccessTokenResult(String json)
at Facebook.FacebookOAuthClient.<ExchangeCodeForAccessTokenAsync>b__6(String json)
at Facebook.FacebookOAuthClient.<>c__DisplayClass9.<OAuthRequestAsync>b__8(Object o, OpenReadCompletedEventArgs e)
at FluentHttp.HttpHelper.OnOpenReadCompleted(OpenReadCompletedEventArgs args)
at FluentHttp.HttpHelper.ResponseCallback(IAsyncResult asyncResult, Object userToken)
at FluentHttp.HttpHelper.OpenReadAsync(Object userToken)
at FluentHttp.HttpHelper.OpenReadAsync()
at Facebook.FacebookOAuthClient.<>c__DisplayClass9.<OAuthRequestAsync>b__8(Object o, OpenReadCompletedEventArgs e)
at FluentHttp.HttpHelper.OnOpenReadCompleted(OpenReadCompletedEventArgs args)
at FluentHttp.HttpHelper.ResponseCallback(IAsyncResult asyncResult, Object userToken)
at FluentHttp.HttpHelper.<>c__DisplayClass2.<OpenReadAsync>b__0(IAsyncResult ar)
at System.Net.Browser.ClientHttpWebRequest.<>c__DisplayClassa.<InvokeGetResponseCallback>b__8(Object state2)
at System.Threading.ThreadPool.WorkItem.WaitCallback_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadPool.WorkItem.doWork(Object o)
at System.Threading.Timer.ring()
Edit
Reply
Reply with quote
Bob_12345
Today at 10:24 PM
I think the indexer in that Json object implementation is failing. It's really rendering the whole application useless. I think the problem is here, but I'm not 100% certain:
private object BuildExchangeCodeForAccessTokenResult(string json)
{
var returnParameter = new JsonObject();
FacebookUtils.ParseQueryParametersToDictionary("?" + json, returnParameter);
// access_token=string&expires=long or access_token=string
// Convert to JsonObject to support dynamic and be consistent with the rest of the library.
var jsonObject = new JsonObject();
jsonObject["access_token"] = returnParameter["access_token"]; <<<<<<<<Here
....
//Since his/her indexer implementation for JsonObject in JsonSimple.CS, no check for "ContainsKey":
public object this[string key]
{
get { return _members[key]; }
set { _members[key] = value; }
}
Edit
Reply
Reply with quote
prabirshrestha
Coordinator
Today at 10:28 PM
seems like it needs the following line of code
var jsonObject = new JsonObject();
if(jsonObject.ContainsKey("access_token"))
jsonObject["access_token"] = returnParameter["access_token"];
could you either file a new issue or send a pull request.
thanks,
prabir