Click here to Skip to main content
15,868,016 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
I integrated facebook SDK, I am doing this to post data on the wall

C#
FacebookClient fb = new FacebookClient(App.AccessToken);

           fb.PostCompleted += (o, e) =>
           {
               if (e.Error != null)
               {
                   Dispatcher.BeginInvoke(() => MessageBox.Show(e.Error.Message));
                   return;
               }

              var result = (IDictionary<string, object>)e.GetResultData();

               Dispatcher.BeginInvoke(() =>
               {
                   MessageBox.Show("Posted Open Graph Action, id: " + (string)result["id"], "Result", MessageBoxButton.OK);

               });
           };


But getting exception,
An exception of type 'System.InvalidCastException' occurred in fbtest.DLL but was not handled in user code

Additional information: Unable to cast object of type 'System.Boolean' to type 'System.Collections.Generic.IDictionary`2[System.String,System.Object]'.
Posted
Updated 15-May-14 6:02am
v3
Comments
[no name] 15-May-14 8:17am    
And your question/problem is what? Check the return value from whatever e.GetResultData is. It's probably not a dictionary.
Member 10801309 15-May-14 8:26am    
I am getting bool type data in 'e' which is showing 'TRUE'. I checked that by using break point.

and because of this exception i am not able to post to facebook wall.
Member 10801309 15-May-14 8:49am    
It is showing in additional information Unable to cast object of type 'System.Boolean' to type 'System.Collections.Generic.IDictionary

How to solve this exception i am not getting it.
[no name] 15-May-14 8:52am    
Well it's fairly easy. Stop trying to stuff your bool into a dictionary that takes a string and an object.
Member 10801309 15-May-14 9:05am    
sir, then what should i do, i changed that way also and checked i am getting same exception. i got your point, but what should i do if object o is of value type bool? then how should i get it? i did different way, but its not working.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900