Silverlight and SharePoint: Getting Started

So people are always asking me how do I get Silverlight to work in SharePoint?  Then Paul Galvin and some other people told me why not post the steps.  So here is what you want to do:

  1. Get Visual Studio 2008 and download SP1 from  The installer may stick at one part and may take an hour or two, so make sure you leave tons of time to spare.
  2. Get the Microsoft Silverlight Tools for Visual Studio 2008 with SP1 from
  3. Get Expression Blend 2.0 from
  4. Download Expression Blend SP1 from
  5. Create a new Silverlight Application using the Silverlight Application Template in Visual Studio 2008 and Expression Blend 2.0

SharePoint specific instructions:

  1. Create a new  Virtual Directory on your SharePoint Application in IIS (c:\inetpub\wwwroot\wss\virtualdirectories\webappfolder\) called ClientBin.  Make sure the directory has Read and Run Permissions.  This directory is where you will put all your compiled Silverlight files (XAP files).
  2. Check the MIME Types in IIS to see if .XAP and .XAML are included (this is added in Server 2008 automagically, but not necessarily in Server 2003).  If these entries are not included add them by using the new button and type in Extension: XAML MIME Type:application/xaml+xml and for the second entry Extension: XAP MIME Type:application/x-silverlight-app.  Adding these extensions as MIME Types makes them trusted extensions.
  3. Add the System.Web.Silverlight.dll to the Global Assembly Cache (click on Start and then Run and type in Assembly and hit Enter, you can drag the assembly into this window). 
    Note: Once you install the Silverlight Extensions for Visutal Studio this should be in the c:\program files directory under the SDK.
  4. Add a Safe Control to your Web .Config File by navigating to the IIS folder for your SharePoint Application (c:\inetpub\wwwroot\wss\virtualdirectories\webappfolder\).  Open the file in NotePad or another editing program and look for the <SafeControls> Tag.  Add this tag at the end of the entries:
    <SafeControl Assembly="System.Web.Silverlight, Version=, Culture=neutral,PublicKeyToken=31bf3856ad364e35" Namespace="System.Web.UI.SilverlightControls" TypeName="*" Safe="True" />
  5. Copy your XAP File into the ClientBin Directory you created above.
  6. Create a SharePoint Webpart and add a reference to System.Web.UI.SilverlightControls and add a using statement.  You should be able to create a new control and reference it in the CreateChildControls like such:
    public Silverlight MySilverlightControl;
    protected override void CreateChildControls()
           MySilverlightControl = new Silverlight();
           MySilverlightControl.ID = "slControl";
           MySilverlightControl.Source = "/ClientBin/MyXAPFile.xap";

These are pretty much all the steps you need to follow to use a Silverlight Control in a webpart.  You need to also remember that you cannot directly reference the SharePoint Object Model in a Silverlight Control.  You can use the SharePoint Webservices or create your own webservice.  Silverlight renders like a client side javascript application and does not work like an ASP .Net Application.  It is more of a presentation layer than a data layer.  If anyone has any comments, questions, or concerns let me know.

Print | posted on Thursday, November 20, 2008 2:57 PM


# re: Silverlight and SharePoint: Getting Started

Left by Gary Payne at 11/20/2008 3:49 PM
Gravatar Hi Becky, good to see some clear instructions for every step!

Another approach that is a simpler way of surfacing a Silverlight app in a web part page is to host the XAP file in a document library and reference that file in an OBJECT tag in a content editor web part. Have a look at my post at for details.

# re: Silverlight and SharePoint: Getting Started

Left by MOSSLover at 11/20/2008 3:56 PM
Gravatar Phil Wicklund posted a 2 part entry on the same thing...Honestly, I'm sure there is about 50 ways to do the same thing. I also noticed someone used a document library to hold the XAP files. There is a SilverPart for SharePoint on CodePlex. I'm hoping the next version of SharePoint is a little more integrated with media files now that Silverlight is gaining more clout.

# re: Silverlight and SharePoint: Getting Started

Left by Greg Farquhar at 12/11/2008 9:58 PM
Gravatar I am attempting to do just this. I have checked and rechecked all that you say, and it still does not work. I am adding two controls, a simple lable and then my silverlight control. I can see the label but no more.

I have a WIN2008 desktop, running VS2008, with V1.2 of the extensions.

My silverlight control works from a web app OK, but not from WSS. WSS is installed locally as well.

Don't suppose you have any suggestions. I am quite new at WSS, Silverlight is not a problem.

Greg Farquhar

# re: Silverlight and SharePoint: Getting Started

Left by Niklas Saers at 2/20/2009 1:43 AM
Gravatar Hi Becky, your name turned up everywhere when I searched for Silverlight/Sharepoint developers on Twitter. I'm happy you're keeping a blog and will be following it. :-)

You say "You can use the SharePoint Webservices", do you have any references as to how? Last I checked the SharePoint services were unavailable as Silverlight didn't have all the plumbing to consume them, and the recommended strategy was writing your own services, preferably with JSON, on top of the SP Object model. I'm doing that now for my current project, but I'd VERY much like to toss the added complexity overboard :-)

# re: Silverlight and SharePoint: Getting Started

Left by MOSSLover at 3/1/2009 4:37 AM
Gravatar I have never done anything with JSON, but I look a good challenge and when I have time (if I ever do again) will try. Consuming the SharePoint Services so far entail Linq to XML and another webservice from what I have seen. What I have since learned is writing your own webservice using the object model and parsing it into an xmldoc, then converting it into a Linq Xdocument works a lot nicer.

# re: Silverlight and SharePoint: Getting Started

Left by SC at 9/7/2009 7:30 PM
Gravatar Hi Becky,

This is a great example for integrating sharepoint and silverlight for sharepoint developers like me.Thanks a lots for your post.But IMHO creating a web part for Sharepoint does not have much use if we do not access the Sharepoint object model in it.....Can you write a post where we access the SHarepoint Object model in a Silverlight web part.Thanks in advance.

# re: Silverlight and SharePoint: Getting Started

Left by SC Vinod at 9/8/2009 5:55 AM
Gravatar Hi Becky, Thanks a lots for this.I want use Sharepoint object model a lots in web part.Can you write post about accessing the Sharepoint object model in Silverlight.Thanks in advance.

# re: Silverlight and SharePoint: Getting Started

Left by donesh at 9/13/2009 9:54 PM
Gravatar Hi Becky,

Can we deploy a silvelight application with a WCF service in this way.....will it work??

Your comment:


Copyright © MOSSLover

Design by Bartosz Brzezinski

Design by Phil Haack Based On A Design By Bartosz Brzezinski