GetFriendsAppUsers() sometimes returning null?

Aug 2, 2008 at 2:07 AM
Edited Aug 2, 2008 at 9:29 PM
One of my users is reporting an error when trying to invite friends to join my app.  I'm unable to reproduce her error, but I do see an event log entry when it occurs (it appears to occur to others as well):

<begin error message>
Exception information:
    Exception type: NullReferenceException
    Exception message: Object reference not set to an instance of an object.
Request information:
    Request URL: http://XXXXXXXX/InviteAFriend.aspx
    Request path: /XXXXXXXX/InviteAFriend.aspx
    User host address: XXXXXXXX
    Is authenticated: False
    Authentication Type: 
    Thread account name: NT AUTHORITY\NETWORK SERVICE
Thread information:
    Thread ID: 13
    Thread account name: NT AUTHORITY\NETWORK SERVICE
    Is impersonating: False
    Stack trace:    at Facebook.API.FacebookAPI.GetFriendsAppUsers()
   at InviteAFriend.SendButton_OnClick(Object sender, EventArgs e)
   at System.Web.UI.WebControls.Button.OnClick(EventArgs e)
   at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument)
   at System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
   at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
   at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
<end error message>

I believe the problem is that GetFriendsAppUsers() is somehow returning null but I can't reproduce or confirm this.  Before I get too deep into debugging/tracing this off my production server, I'm wondering if anyone else has had similar problems and/or has a solution?


<UPDATE 8/2/2008>
I ended up creating my own version of GetFriendsAppUsers that uses the friends.GetAppUsers API call provided by Facebook and these errors went away.  It seems as though the toolkit uses an FQL query instead of friends.GetAppUsers.  The reason for this is explained in the comments in the toolkit:

// Build an FQL query for retrieving friends that are also users of this application
            // Use FQL instead of direct REST call to insulate from REST changes
            // Similar to friends.getAppUsers in REST api

I understand the reasoning made by the developer but I would like to suggest that going forward, the Toolkit use the Facebook API calls whenever possible because it seems as though FQL queries do not always behave the same as their API equivalents, despite what the FB Wiki documentation says (  I say this because this is not the first time that this has happened.  I also had to create my own version of GetGroupMembers() because the Toolkit version uses an FQL query that behaves differently than facebook.groups.getMembers that is provided in the API.