4
Vote

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

description

I downloaded the binaries 0.3.0.0 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)

comments

mpsundar wrote Dec 22, 2008 at 8: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.

Phani...

mpsundar wrote Dec 22, 2008 at 9:02 AM

Please check the link below
http://developers.facebook.com/news.php?blog=1&story=45
which could be the reason for the problem.

mkagan wrote Jan 21, 2009 at 8:20 PM

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

Thanks,
Marc

pmscheffler wrote Jan 22, 2009 at 12: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.

Peter

mkagan wrote Jan 22, 2009 at 9:27 PM

Where exactly did you make that change in the code?

Thanks,
Marc

RangerPT wrote Jan 23, 2009 at 3:09 PM

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

wrote Feb 12, 2009 at 5:46 PM

cmoya wrote Feb 26, 2009 at 3:24 AM

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

wrote Mar 2, 2009 at 11:23 AM

wrote Apr 13, 2009 at 9:11 AM

wgraham wrote Jul 15, 2010 at 1:44 AM

Confirming Peter's fix.

wrote Feb 21, 2013 at 10:58 PM