Jason Z Jason Z - 2 months ago 7x
C# Question

cannot find the SPSite name space

I am unable to find the name space for the


I have imported these so far:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using Microsoft.SharePoint;
using System.Collections;
using Microsoft.SharePoint.Client;
using Microsoft.SharePoint;
using System.Data.SqlClient;
using SP = Microsoft.SharePoint.Client;
using System.Data;

namespace GrandPermission
class Program
static void Main(string[] args)
SPSite oSPSite = new SPSite("http://spdevserver:1002/");

still has red line under it.
enter image description here
enter image description here


This error occurs since SPSite class is a part of Server Side Object Model API:

Server Side Object Model API could be utilized only on machine where SharePoint Server/Foundation is installed.

Since you are using Client Object Model API (referenced assembly in your project Microsoft.SharePoint.Client.dll is a part of SharePoint Server 2013 Client Components SDK) i would recommend to utilize this API.

So, the line:

SPSite oSPSite = new SPSite("http://spdevserver:1002/");  //SSOM

could be replaced with:

using(var ctx = new ClientContext("http://spdevserver:1002/"))
    var site = ctx.Site;