I have write a code that contains SPSite and I got this error CS0246: The type or namespace name 'SPSite' could not be found (are you missing a using directive or an assembly reference?)
I have tried downloading Microsoft.SharePoint from the nuget site here https://www.nuget.org/packages/Microsoft.SharePoint.dll/ and then I have put the package in the right folder and still I have the same error
using System;
using System.Data;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
using System.Text;
using System.Threading.Tasks;
using System.Security;
using System.Net;
using System.Configuration;
using System.Collections.Specialized;
using System.Runtime;
using Microsoft.SharePoint;
using System.Reflection;
using Microsoft.SharePoint.Client;
using SP = Microsoft.SharePoint.Client;
protected void getList()
{
string strUrl = " SharePoint SITE ";
using (SPSite oSite = new SPSite(strUrl))
{
using (SPWeb oWeb = oSite.OpenWeb())
{
SPList list = oWeb.Lists["Workplan"];
foreach (SPField field in list.Fields)
{
Console.WriteLine(field.Title);
}
}
}
}
after adding the package that I download in the right place I expected for the error to fade away still it's there. Help please!
Install-Package ....
? – Crowcoderusing SP = Microsoft.SharePoint.Client;
, do you needSP.SPSite
? – doctorloveSPSite
is a server-side type but your code references the client libraries. You don't needSPSite
to work with the client libraries at all. Did you copy some server-side code and tried to use it from a client perhaps? – Panagiotis Kanavos