c# - cannot find the SPSite name space -
i unable find name space spsite
i have imported these 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/"); } } }
and spsite
still has red line under it.
this error occurs since spsite class part of server side object model api:
server side object model api utilized only on machine sharepoint server/foundation installed.
since using client object model api (referenced assembly in project microsoft.sharepoint.client.dll
part of sharepoint server 2013 client components sdk) recommend utilize api.
so, line:
spsite ospsite = new spsite("http://spdevserver:1002/"); //ssom
could replaced with:
using(var ctx = new clientcontext("http://spdevserver:1002/")) { var site = ctx.site; //... }
Comments
Post a Comment