This project is read-only.

Unable to cast object of type 'Facebook.Service.Core.JsonObject' to type 'System.Collections.ArrayList'.

Dec 7, 2007 at 3:12 AM
Edited Dec 7, 2007 at 4:41 AM
Hi there,

Receiving the error "Unable to cast object of type 'Facebook.Service.Core.JsonObject' to type 'System.Collections.ArrayList'."

This happens for a specific user, when I make the call:

fbApplication.Service.Users.GetUser(iFriendUid.ToString(), "name, pic_square")

I assume that this is because the call is returning a null?

Is this a bug? or maybe a user permissions issue?

If it's not a bug, what's the best way to cope with it? Just use a try / catch?



btw: have downloaded the latest release and it is still a problem (thought it might be related to )
Dec 10, 2007 at 3:33 PM
This seems to happen when the uid is invalid for one reason or another. In my application, I've had several instances where a user has removed their Facebook profile, but is still referenced within the application because they're on a "leader" board. Then, whenever that page is displayed, I get that error.
Dec 10, 2007 at 11:29 PM
Hi there Daniel,

Thanks for that feedback - I don't think thats the case here as their profile appears OK in other places.

How do you handle the exception when it happens on your app? particularly in a leaderboard scenario where you're pulling a list of ids?


Dec 21, 2007 at 8:07 AM
I believe its happening because Facebook doesn't send a list of objects when there is just one object - seems they have a pretty loose contract. I am changing various places in the code that expect an ArrayList to check if the response was actually a dictionary, and treat the response as a single item response.
Dec 27, 2007 at 3:01 AM
I think the problem is that in your app you try to get some information of ones that doesn't allow you get their information.
I debug the code and find out that this situation the result is not an ArrayList.
By the way, you can get all of your app user's friendid, but not all information of your app user's friends