This project is read-only.

FacebookRequest.cs:line 180 - Unable to cast object of type 'System.Int32' to type 'System.String'.


I downloaded the binaries and got this error... the downloaded the source, and got the very same error...
Recompiled for .Net 3.5, same error... I'm using the Samples/HelloWorldFBML sample.
So far, I traced this to the UserID string returned by Facebook. Am I doing something wrong or this is a known bug? If it is, anybody knows a workaround?
Error transcript follows:
Exception Information
Unable to cast object of type 'System.Int32' to type 'System.String'.
at Facebook.Service.Core.FacebookRequest.CreateSession(String authToken, String& userID, Boolean& expires, String& secret) in \Facebook.NET\Framework\Service\Core\FacebookRequest.cs:line 180
at Facebook.Web.FacebookFbmlSession.Initialize(HttpContext context) in \Facebook.NET\FrameworkWeb\Web\FacebookFbmlSession.cs:line 44
at Facebook.Web.FacebookApplication.OnPagePreLoad(Object sender, EventArgs e) in \Facebook.NET\FrameworkWeb\Web\FacebookApplication.cs:line 581
at System.Web.UI.Page.OnPreLoad(EventArgs e)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)


mpsundar wrote Dec 22, 2008 at 9:57 AM

Hi All,
I am also facing the same problem with the dll. This was working fine till last week and when the new UI in facebook came up for creating the application this problem has started. Please let me know what can be done to resolve this issue. As far as I think it should be the problem with the dll we need to modify the source code. Please help

Thanks in advance.


mpsundar wrote Dec 22, 2008 at 10:02 AM

Please check the link below
which could be the reason for the problem.

mkagan wrote Jan 21, 2009 at 9:20 PM

I am also having this problem. Has anyone found a resolution?


pmscheffler wrote Jan 22, 2009 at 1:10 PM

There is a bug in the code. You need to explicitly cast the userid. I came across this myself a couple weeks back.

Here's how I fixed it:
                    userID = result["uid"].ToString();
I did that a few weeks ago and haven't seen an issue since.


mkagan wrote Jan 22, 2009 at 10:27 PM

Where exactly did you make that change in the code?


RangerPT wrote Jan 23, 2009 at 4:09 PM

Make the change here:
\Framework\Service\Core\FacebooRequest.cs Line 180

wrote Feb 12, 2009 at 6:46 PM

cmoya wrote Feb 26, 2009 at 4:24 AM

Make sure your CallBack URL, etc have a trailing slash. This solved the problem for me.

wrote Mar 2, 2009 at 12:23 PM

wrote Apr 13, 2009 at 10:11 AM

wgraham wrote Jul 15, 2010 at 2:44 AM

Confirming Peter's fix.

wrote Feb 21, 2013 at 11:58 PM