Monday, September 19, 2011

SharePoint 2010: The Client Object Model


Referred URLs:

If you want to access SharePoint Server 2007 Data today, you have two ways of doing it (based on your needs):

1. Writing a Server Application

o This application resides in server

2. Writing a Client Application

o This client application can run from any other server or a desktop

How are we building these Server and Client applications today?

Server Application


We interact with the Server Object Model, which are nothing but SharePoint APIs and build applications.

For example:

List<Announcement> announcements = new List<Announcement>();

SPSite site = SPContext.GetContext(HttpContext.Current).Site;

using (SPWeb curWeb = site.OpenWeb())


SPList lstAnnouncements = curWeb.Lists[new Guid(LibraryName)];

//rest of the code


Client Application


We use the SharePoint Web Services which then interacts with the SharePoint API. Usually, developers either build their own set of web services which exposes only certain methods/functions they want to expose to the application or consume the default out of the box SharePoint web services. This becomes difficult if you are going write rich client applications such as Silverlight, or Javascript applications and most of the time accessing SharePoint data via web services is complicated. That is why, I am not going to show you an example code!

The Future of SharePoint Client Applications

SharePoint 2010 introduces the new Client Object Model. From the sneak peak videos:

“The Client Object Model (OM) is a new programming interface for SharePoint 2010 where code runs on a user’s client machine against a local object model and interacts with data on the SharePoint Server. Client OM methods can be called from JavaScript, .NET code or Silverlight code and makes building rich client applications for SharePoint easy.”

So, how things are going to change?


One API to rule them all – Yep, whether its WPF or Windows Forms or Silverlight or Javascript – your code uses Client Object Model to interact with the SharePoint site to access the data. Now, there is something common that everybody can use instead of creating their own wrapper services to access SharePoint data!

Any code sample?

The only source of information available for now is the Developer Sneak Peak Video.

In the video, a Silverlight application is built using the Client Object Model.

The assemblies added to the project are:


  • Microsoft.SharePoint.Client.Silverlight.dll
  • Microsoft.SharePoint.Client.Silverlight.Runtime.dll

And also there is a using statement added in the code behind:


using Microsoft.SharePoint.Client;

And the code showcasing this new Client Object Model:


You can explore the Microsoft.SharePoint.Client namespace in the SharePoint 2010 Technical Preview Documentation


What are the different Client OM supporting in the SharePoint 2010 API? [Client API]

  1. .NET Managed Client - Implemented in .NET CLR. I mean we use this in Web, Windows and Console applications.
  2. Silverlight Client - You can use the SharePoint objects in Silver light coding. Wow, this is going to be a huge advantage to  the Silverlight applications which can be integrated into SharePoint. Before we don't have access to SharePoint objects inside Silverlight context.
  3. ECMAScript Client - Through javascript too, we can get context and do manipulations to SharePoint objects. Do you think it's possible? Yes, its a brilliant way of thinking from Microsoft SharePoint team and this will help in great scenarios. Will explain later in this article.

Why Client Object Model comes into the picture? Are there any specialties of them?

The main started point to think by SharePoint team are as follows.

  1. Is it really necessary to have SharePoint installed on server for SharePoint development? - Yes, in SharePoint 2007 you have to install SharePoint on the server to write code and test it.
  2. What is the advantage of writing more web services to serve what the clients are looking for? - This is completely not a feasible solution to give or expose web services for each and every single requirement to get and manipulate data. It has plenty of limitations and if Microsoft exposes 500 web services and you didn't find what you really need and they are just waste. Instead write whatever you want and use them.
  3. The great thinking and beautiful solution to the people who don't allow server side coding in the SharePoint sites is ECMAscript client OM. You can create a simple javascript file and deploy into the server to get what you needed. As we know, most of the clients don't allow server side coding but they want something to be developed. In SharePoint 2007 it's very difficult to get this job done. But now in SP 2010 very easy.

So, these things take into high priority and makes them to come up with a great solution in the form of Client Object Model. The great advantage of it is completely looks [Syntax] like the SharePoint Object Model. So, nothing new for developers and no confusion. Infact very simple to manage and write code. 

SharePoint object model syntax:

Server side syntax

Client side syntax









Now, I believe you have understood the Client OM concept. Now, we will discuss a little bit about technical implementation.
SharePoint 2010 provides the client support files to refer the SharePoint objects and communicate with the SharePoint server. Below are the details.

ForManaged Client

DLL's needed : Microsoft.SharePoint.Client.dll, Microsoft.SharePoint.Client.Runtime.dll. Find these files in the 14/ISAPI folder. Usually, the location would be at "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\ISAPI".


Microsoft.SharePoint.Client.Silverlight.dll and Microsoft.SharePoint.Client.Silverlight.Runtime.dll. They find at "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\LAYOUTS\ClientBin".


SP.js file - The file fund at "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\LAYOUTS".

.NET Managed Deployment

Microsoft SharePoint Foundation 2010 installs Microsoft.SharePoint.Client.dll and Microsoft.SharePoint.Client.Runtime.dll in %ProgramFiles%\Common Files\Microsoft Shared\web server extensions\14\ISAPI for easy access in development. You must have both Microsoft.SharePoint.Client.dll and Microsoft.SharePoint.Client.Runtime.dll to develop a solution remotely with the .NET managed object model. For a Windows Forms, Windows Presentation Foundation (WPF), or other application that calls the .NET managed SharePoint Foundation client APIs, to function, the client computer must have the SharePoint Foundation client DLLs installed. The client DLLs must be distributed with the application by using Microsoft's SharePoint Foundation 2010 Client Object Model Redistributable.

For an example that shows how to create a console application that uses the .NET managed object model, see Creating a Basic SharePoint Foundation Client Application.

clip_image014Silverlight Deployment

For Silverlight client installations, Microsoft SharePoint Foundation 2010 deploys Microsoft.SharePoint.Client.Silverlight.dll and Microsoft.SharePoint.Client.Silverlight.Runtime.dll into the special scripts-only folder %ProgramFiles%\Common Files\Microsoft Shared\web server extensions\14\TEMPLATE\LAYOUTS\ClientBin. This folder is designed to be a standard place for hosting assemblies that are used in Silverlight. You must have both Microsoft.SharePoint.Client.Silverlight.dll and Microsoft.SharePoint.Client.Silverlight.Runtime.dll to develop a solution remotely with the Silverlight object model. The author of a Silverlight application can package the client-side DLLs together in the .xap file for download. It is also possible to cache the Silverlight DLLs.

For information about how to implement the SharePoint Foundation 2010 Silverlight object model in a Silverlight application, see Using the Silverlight Object Model.

Thursday, September 15, 2011

8 important manners you should teach your little ones

We all want to raise our little ones to be polite and well behaved, and learning those lessons starts at home. It's never too early to teach your little ones basic manners! Here are eight of the most important manners you should try to teach your little ones before they go to school. They won't remember them all, or get them right every time, but patience and perseverance should get you through:

1.    Always say please and thank you.

Whether they're activities as small as giving your little one a snack, or them asking if they can play in the garden, always reinforce the importance of saying please and thank you. No matter how young your children are, you can't start enforcing this rule too early!

2.    Table manners

When your tiny tots are just learning to eat at the table, start teaching them the manners you'd like them to have for the rest of their lives! Rules like not eating with their mouths open, or not putting their elbows on the table, are good life lessons for your children to learn as soon as possible.

3.    Play dates

When you're little ones go on play dates, or to birthday parties, remind them to thank their friends parents for having them over. If you aren't going to be attending the play date or event with your little one, ensure your little ones know they should treat their friends parents (and all grown-ups) with the same respect they treat you.

4.    Birthday party etiquette

It's often said that kids go wild at birthday parties - all the sweet snacks and fun can make little ones get excited, and sometimes forget their manners. But no matter how excited your little one is on their birthday, there are some manners they shouldn't forget: to open their presents thoughtfully (not ripping off the paper, or tossing the present to one side as soon as they've seen it) and to say thank you for every gift, and to every attendee.

5.    Mind the language

There will come a moment every parent dreads: the moment your little one swears. And then finds it funny! The worst thing you can do in this scenario is laugh. Let them know that you already know that word, you think it's unpleasant, not funny, and ask your little one not to use it again!

6.    Don't be mean

Kids tease each other, and they find it funny. But this can sometimes go a step too far and lead to bullying. Make sure your little ones don't call others mean names, and don't make fun of anyone for any reason. Ganging up on someone else is cruel, not clever.

7.    Excuse me!

Once your little ones have mastered saying please and thank you, teach them to say excuse me. It's the polite thing to say when you have to interrupt someone, or bump into somebody.

8.    TMI!

There are some things that are too much information, and that your little ones shouldn't talk about in public! These include genitals, poo, nose picking, and all the other gory things that amuse kids!