Create Event using library FB.Net 2.0

May 27, 2009 at 12:23 PM

Hi

I am trying to create an event using the code below but getting exception on events.create() function.

Exception : ActiveX control '8856f961-340a-11d0-a96b-00c04fd705a2' cannot be instantiated because the current thread is not in a single-threaded apartment.

Code to create event:  

 // ApplicationKey and Secret are acquired when you sign up for an
        //application
        _fbService.ApplicationKey = "app_key";
        _fbService.Secret = "app_secret";
        _fbService.IsDesktopApplication = false;
               
        string sessionKey = Session["Facebook_session_key"] as String;

        // When the user uses the Facebook login page, the redirect back
        // here will have the auth_token in the query params
        string authToken = Request.QueryString["auth_token"];

        // We have already established a session on behalf of this user
        if (!String.IsNullOrEmpty(sessionKey))
        {
            _fbService.SessionKey = sessionKey;
            _fbService.uid = (long)Session["Facebook_userId"];
        }
        // This will be executed when Facebook login redirects to our page
        else if (!String.IsNullOrEmpty(authToken))
        {
            _fbService.CreateSession(authToken);
            Session["Facebook_session_key"] = _fbService.SessionKey;
            Session["Facebook_userId"] = _fbService.uid;
            Session["Facebook_session_expires"] = _fbService.SessionExpires;

        }
        // Need to login
        else
        {
            Response.Redirect(@"http://www.Facebook.com/login.php?api_key=" + _fbService.ApplicationKey + @"&v=1.0\");
        }

        if (!IsPostBack)
        {
            // Use the FacebookService Component to populate Friends
            FriendList1.Friends = _fbService.friends.getUserObjects();
            facebook.Schema.facebookevent fbevent = new facebook.Schema.facebookevent();
            fbevent.eid = 1;
            fbevent.name = "Testing Event";
            fbevent.tagline = "testing teg line";
            fbevent.nid = 1;
            fbevent.pic = "test.gif";
            fbevent.pic_big = "test.gif";
            fbevent.pic_small = "text.gif";
            fbevent.host = "host name";
            fbevent.description = "description goes here";
            fbevent.event_type = "party";
            fbevent.event_subtype = "birthday party";
            fbevent.start_time = 1;
            fbevent.end_time = 2;
            fbevent.creator = 1;
            fbevent.update_time = 3;

            facebook.Schema.location _location = new facebook.Schema.location();
            _location.street = "630 Vernon";
            _location.city = "Glencoe";
            _location.state = "IL";
            _location.zip = "60022";

 

            fbevent.location = _location.ToString();
            _fbService.GetExtendedPermission(facebook.Types.Enums.Extended_Permissions.create_event);
            _fbService.events.create(fbevent);

 Please help!

Oct 15, 2009 at 8:40 PM

Hi,

I'm having the same problem.  Did you ever get this issue resolved?

Thanks!
Jason