How to use the client object model with SharePoint2010
- by ybbest
In SharePoint2010, you can use client object model to communicate with SharePoint server. Today, I’d like to show you how to achieve this by using the c# console application. You can download the solution here.
1. Create a Console application in visual studio and add the following references to the project.
2. Insert your code as below
ClientContext context = new ClientContext("http://demo2010a");
Web currentWeb = context.Web;
context.Load(currentWeb, web => web.Title);
context.ExecuteQuery();
Console.WriteLine(currentWeb.Title);
Console.ReadLine();
3. Run your code then you will get the web title displayed as shown below
Note:
If you got the following errors, you need to change your target framework from .Net Framework 4 client profile to .Net Framework 4 as shown below:
Change from
TO