Nick Grattan's Blog

About Microsoft SharePoint, .NET, Natural Language Processing and Machine Learning

Credentials, SharePoint Client Object Model and Silverlight

with 4 comments

When using the SharePoint Client Object Model in Silverlight, you need to add references to the Client Object Model assemblies prepared for Silverlight:

These assemblies are located in the “14” hive: \14\TEMPLATE\LAYOUTS\ClientBin. Note that when using the Client Object Model in other application types you use the libraries located in the ISAPI folder in the “14” hive (Microsoft.SharePoint.Client.dll and Microsoft.SharePoint.Client.Runtime.dll).

Before executing Client Object Model calls you need to get a ClientContext object through which calls can be made. When running in a Silverlight application you can do this so:

            ClientContext clientContext = ClientContext.Current;

However, “ClientContext.Current” is only initialized when the Silverlight application is running on a page in a SharePoint site. If you run the Silverlight application on a page in another web site “ClientContext.Current” returns NULL. Creating your own ClientContext object is described in this post – the ClientContext class has a “Credentials” property which can be set through creating a new “NetworkCredentials” object.

But here’s the rub – the Silverlight Client Object Model does not support the Credentials property. So it would seem that Silverlight applications using the Client Object Model can only run in SharePoint sites.

So what about adding references to Microsoft.SharePoint.Client.dll and Microsoft.SharePoint.Client.Runtime.dll instead? Doing this causes an error stating that the assemblies have not been prepared for the Silverlight environment.

Written by Nick Grattan

May 20, 2010 at 8:01 am

4 Responses

Subscribe to comments with RSS.

  1. Thanks Nick. It helped a ton. Keep posting.


    February 26, 2011 at 1:33 am

  2. Well, actually this post does not help. I have the same problem. So, how DO you solve this and pass credentials?
    I have a silverlight application running on IIS and want to use the Client OM.



    February 22, 2012 at 1:48 pm

    • Yes, this post points out the issue but does not supply a solution – I don’t think there *is* a solution.

      Nick Grattan

      February 22, 2012 at 2:03 pm

  3. having the same trouble. i am using lists web service under _vti_bin


    May 24, 2012 at 10:26 am

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: