facebook login problem

Jan 31, 2011 at 9:13 AM


I am using C# Facebook SDK version 4.2.1 steps i am using for implement login with facebook and many other features of facebook app like publish on wall etc.

1. web.config setting

<section name="facebookSettings" type="Facebook.FacebookConfigurationSection"/>
        <section name="canvasSettings" type="Facebook.Web.CanvasConfigurationSettings"/>
    <facebookSettings appSecret="My App Secret" appId="My facebook App ID"/>
    <canvasSettings canvasPageUrl="http://apps.facebook.com/graphtoolkit/" authorizeCancelUrl="http://apps.facebook.com/graphtoolkit/home/cancel"/>


            <add verb="*" path="facebookredirect.axd" type="Facebook.Web.FacebookAppRedirectHttpHandler, Facebook.Web"/>


2.login.aspx page

 <script src="http://connect.facebook.net/en_US/all.js" type="text/javascript"></script>
    <div id="fb-root"></div>
        window.fbAsyncInit = function () {
            FB.init({ appId: 'My appID' status: true, cookie: true,
                xfbml: true
        (function () {
            var e = document.createElement('script');
            e.type = 'text/javascript';
            e.src = document.location.protocol +
            e.async = true;
        } ());
    <fb:login-button onlogin=window.location.reload(true); autologoutlink="false" size="small" style="margin-left:2px;" show-faces="false"></fb:login-button>'
        <asp:Button ID="Button2" runat="server" Text="Button" onclick="Button2_Click" />
    &nbsp;<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
        <asp:Label ID="Label2" runat="server" Text="Label"></asp:Label>
        <asp:Label ID="Label3" runat="server" Text="Label"></asp:Label>
        <asp:Image ID="Image1" runat="server" />

3. login.aspx.cs page

 protected void Page_Load(object sender, EventArgs e)
        FacebookApp app = new FacebookApp();
        Authorizer authorizer = new Authorizer(app);
        authorizer.Perms = "email";

        if (authorizer.IsAuthorized())
            //Response.Redirect(HttpUtility.UrlDecode(Request.QueryString["returnUrl"] ?? "~/index.aspx"));
            Label1.Text = app.UserId + " ";
            JsonObject result = (JsonObject)app.Api("/me");
            string firstname = (string)result["first_name"];
            string lastname = (string)result["last_name"];
            Label2.Text = firstname;
            Label3.Text = lastname;
            Image1.ImageUrl = "http://graph.facebook.com/" + app.UserId + "/picture?type=large";
            Label3.Text = "unautherized";



4.Assemblies in bin directory




iv. Newtonsoft.Json.Net35.dll

v. System.Web.Abstractions.dll

vi. System.Web.

vii. System.Web.Mvc.dll

viii. Microsoft.Web.Mvc.dll

5.On server it give error 

Method not found: 'Boolean System.Runtime.Serialization.DataContractAttribute.get_IsReference()'.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.MissingMethodException: Method not found: 'Boolean System.Runtime.Serialization.DataContractAttribute.get_IsReference()'.

Source Error:

Line 24:         authorizer.Perms = "email";
Line 25:
Line 26: if (authorizer.IsAuthorized())
Line 27: {
Line 28: //Response.Redirect(HttpUtility.UrlDecode(Request.QueryString["returnUrl"] ?? "~/footer.aspx"));

6.After all unable to find which assembly server not find

please hlep on this thanks in advance