Welcome to Pete Brown's 10rem.net

First time here? If you are a developer or are interested in Microsoft tools and technology, please consider subscribing to the latest posts.

You may also be interested in my blog archives, the articles section, or some of my lab projects such as the C64 emulator written in Silverlight.

(hide this)

Silverlight Facebook Application – MSDN East Coast News (what I’ve been working on lately)

Pete Brown - 21 September 2008

MSDN East Coast News

My primary Silverlight project for the past couple months has been the Facebook application I’ve been writing for the Microsoft East Coast Developer, Partner and Architect Evangelists: MSDN East Coast News.

For those of you curious about building Facebook applications with Silverlight, I have at least two sessions coming up:
  • MSDN geekSpeak on building facebook applications with Silverlight – Wednesday October 22
  • CMAP Code Camp (Maryland Local event) almost-all-code session on Saturday October 25
You can find the links for those events and others in my upcoming events blog post.

While it isn’t quite ready for everyone to jump on it (hey, it’s still running out of a server in my basement), I thought I’d talk about it just a little. However, if you have a facebook account (and are using the new profile), go ahead and try it out and report back here if you run into any problems, if you like it, have suggestions, anything. Just let me know you tried and and let me know your honest opinion.

MSDN East Coast News is an app which serves three main goals:

  1. Showcase what your local east coast evangelists have been blogging about, and the events they have planned.
  2. Show Silverlight combined with Facebook
  3. Get Silverlight on more desktops

The third is a semi-goal, as it generally goes without saying :) However, we did want to show what it would take to stick a Silverlight app in Facebook.

AIS graciously agreed to fund the development of this for Microsoft, and I’m thankful to them for giving me time to work on this fun application The two project stakeholders from Microsoft were John McClelland and Chad Brooks.

Here are a few screenshots of the application:

MSDN East Coast News - Main Page MSDN East Coast News - Events Page MSDN East Coast News - Video Page MSDN East Coast News - Blogs Page image MSDN East Coast News - Media Player Overlay

As with any RIA, static screenshots are only a part of the story. If you’re interested in the rest, go ahead and try it out.

The tooling story was fairly simple:

  • I did the wireframes in Blend. I don’t normally do that due to the baggage you get by using Blend, but we had some paper mocks to work from and it made sense in this case. The interesting bit here was I was able to gradually add more functionality to the wireframes and evolve the application to its final state.
  • I did the background images in Photoshop
  • I developed the “crabster” in Expression Design, and the rest of the logo in Photoshop
  • I developed the UI in Expression Blend and Visual Studio. Most of the UI is hand-tweaked xaml rather than handled visually in Blend. I’m not sure why it worked out that way, but it did. Sometimes I can just really crank through the xaml in the VS editor. I did use Blend for all the initial VSM states, with hand-tweaking afterwards.
  • I did the database tables using SQL Server Management Studio

The architecture for this is also relatively simple:

Facebook Silverlight Application Architecture

It looks like a lot of moving parts, but except for the interface to Facebook itself, it is architecturally much like we would build any integrated ASP.NET + Silverlight application. The Facebook API was a royal pain, though. Part of the reason the application is in “beta” right now is the Facebook API keeps changing, and the folks making the Dev Toolkit are just trying to keep up. At the last minute, I had to turn off a lot of functionality I had written against the old API (like posting user stories in the profile). I’ll re-evaluate this in a month or so and see if it makes sense to make the changes to code it against the new API.

Note that all the Facebook calls are made server-side, and I only send the interesting bits back to the Silverlight app, via the WCF service.

The key thing to keep in mind when coding a Silverlight facebook application is that you need to pass Facebook session identifying information from the iframe page, down to Silverlight and then back up to your WCF service. That way you preserve the fb session context and can actually make calls to get information about the current user. The way I did that in this application was to use initparams:


API api = ((CanvasIFrameMasterPage)Master).API;

string initParams = 
    string.Format("userId={0},sessionKey={1}", api.uid, api.SessionKey);

silverlightControl.InitParameters = initParams;

Silverlight Application

private void Application_Startup(object sender, StartupEventArgs e)
    // Load the main control
    this.RootVisual = new Page();

    string userid = e.InitParams["userId"];
    string sessionKey = e.InitParams["sessionKey"];

    Model.ApplicationData.Current.Initialize(userid, sessionKey);

That way, I can then pass the information back up to my service calls:

Silverlight Client-Side Service Code

private PlatformServiceCredentials _serviceCredentials;
public void LoadUserInformation()
    ApplicationDataServiceClient client = new ApplicationDataServiceClient();
    client.GetUserInformationCompleted += 
        new EventHandler<GetUserInformationCompletedEventArgs>(client_GetUserInformationCompleted);

The PlatformServiceCredentials class is defined server-side as:

public class PlatformServiceCredentials
    public string UserId { get; set; }

    public string SessionKey { get; set; }

    public PlatformServiceCredentials()

    public PlatformServiceCredentials(string userId, string sessionKey)
        UserId = userId;
        SessionKey = sessionKey;

I’ll post more about the details behind this application in future blog posts. However, here are some of my past posts which cover bits from this application:

Be sure to check out the October 22 MSDN geekSpeak on this topic and, if you’re local, my CMAP Code Camp presentation on Silverlight Facebook application development.

posted by Pete Brown on Sunday, September 21, 2008
filed under:        

3 comments for “Silverlight Facebook Application – MSDN East Coast News (what I’ve been working on lately)”

  1. Pete Brownsays:
    Note: If you visit the application and are not yet logged-in to facebook, facebook will probably redirect you to a 404 page. That's a problem with the transition to the new API and profile layout. I'm hoping they fix that soon, but you never know with FB.

  2. john mullinaxsays:
    Interesting post - unfortunately the app is giving me an error....

    Value was either too large or too small for an Int32.
    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.OverflowException: Value was either too large or too small for an Int32.

    Source Error:

    Line 22: base.AutoAdd = false;
    Line 23:
    Line 24: base.Page_Init(sender, e);
    Line 25: }
    Line 26:

    Source File: \\p-unc-01\content$\msdnroadshow.com\wwwroot\FB\Site.master.cs Line: 24
  3. Pete Brownsays:


    I don't maintain the app anymore, but I was told yesterday that facebook changed something in the API and the app no longer works. I'm not sure if it will be taken down, or if someone will put some work into it.


Comment on this Post

Remember me

7 trackbacks for “Silverlight Facebook Application – MSDN East Coast News (what I’ve been working on lately)”

  1. Dew Drop - September 21, 2008 | Alvin Ashcraft's Morning Dewsays:
    PingBack from http://www.alvinashcraft.com/2008/09/21/dew-drop-september-21-2008/
  2. Community Blogssays:
    Rob Houweling with a Jeff Paries Sneak Preview, Devin Rose with "Mountain Pass Tower Defense"
  3. POKE 53280,0: Pete Brown's Blogsays:
    I’m about to embark on some very different Silverlight application development projects (primary around
  4. Community Blogssays:
    I’m about to embark on some very different Silverlight application development projects (primary around
  5. POKE 53280,0: Pete Brown's Blogsays:
    It seems like Twitter clients get all the attention these days, but not too many folks are doing serious
  6. POKE 53280,0: Pete Brown's Blogsays:
    Prior to joining Microsoft, I worked at a consulting company for a bit over 13 years. Prior to that,
  7. Community Blogssays:
    Prior to joining Microsoft, I worked at a consulting company for a bit over 13 years. Prior to that,