Javascript – SharePoint Server Object model (SPSite & SPWeb)

cjavascriptsharepoint-2010ssis

I'm using VS 2010 on Windows XP. I did download microsoft.sharepoint.client.dll & microsoft.sharepoint.client.Runtime.dll from Microsoft Client Object model on my computer.

I was able to find above dll's in C:\Program Files\Common Files\Microsoft Shared\SharePoint Client, Not at below location. C:\Program Files\Common Files\Microsoft Shared\web server extensions\14\ISAPI — as pointed on some other articles and stackoverflow question.

Task: SSIS & SharePoint Integration and download files from SharePoint site (SP 2010).

Here is the problem. I'm trying to use namespace SPSite and SPWebsite but VS 2010 doesn't recognize. I have add above mentioned dlls as reference and my target framework 4.0.

using (SPSite site = new SPSite(siteUrl)) –Error: The type or namespace SpSite couldn't be found (are you missing using directive or assembly reference).

Looks like i need to install something on Sharepoint Server as Server Object Model.
1. Could you tell me what i need to install on Sharepoint Server.
2. After #1, what do i need to do in C# program so that i can access those Server side object.

Please advice steps in details as i'm a newbie to .Net.

Thanks!!

Best Answer

You are confusing 2 different technologies: Server Object Model and Client Object Model.

The code snippet you posted is Sharepoint Object model and you can only compile/run it on a SharePoint server, but the libraries you referenced are CLient Object Model.

If you want to access Sharepoint functionality remotely (as it appears you do) you need to use Client Object Model.

A sample code using Client Object Model that retrieves all the items from a task list:

ClientContext context = new ClientContext("http://mySharepointSite.com");
List list = context.Web.Lists.GetByTitle("Tasks");
CamlQuery query = new CamlQuery();
query.ViewXml = "<View/>";
ListItemCollection items = list.GetItems(query);

context.Load(list);
context.Load(items);

context.ExecuteQuery();

Check here:

http://www.codeproject.com/Articles/399156/SharePoint-2010-Client-Object-Model-Introduction