C# 4.0 不包含ListItemAllFields的定义
我有以下代码:C# 4.0 不包含ListItemAllFields的定义,c#-4.0,sharepoint-2010,.net-4.0,csom,C# 4.0,Sharepoint 2010,.net 4.0,Csom,我有以下代码: public void ChangeFolderPermission() { SP.ClientContext ctx = new SP.ClientContext("https://sharepoint.oshirowanen.com/sites/oshirodev/"); ctx.Credentials = new NetworkCredential("user", "pass", "domain"); SP.Principal user = ctx
public void ChangeFolderPermission()
{
SP.ClientContext ctx = new SP.ClientContext("https://sharepoint.oshirowanen.com/sites/oshirodev/");
ctx.Credentials = new NetworkCredential("user", "pass", "domain");
SP.Principal user = ctx.Web.EnsureUser("accountName");
var folder = ctx.Web.GetFolderByServerRelativeUrl("folderUrl");
var roleDefinition = ctx.Site.RootWeb.RoleDefinitions.GetByType(SP.RoleType.Reader); //get Reader role
var roleBindings = new SP.RoleDefinitionBindingCollection(ctx) { roleDefinition };
folder.ListItemAllFields.BreakRoleInheritance(true, false); //set folder unique permissions
folder.ListItemAllFields.RoleAssignments.Add(user, roleBindings);
ctx.ExecuteQuery();
}
但以下几行:
folder.ListItemAllFields.BreakRoleInheritance(true, false); //set folder unique permissions
folder.ListItemAllFields.RoleAssignments.Add(user, roleBindings);
给出此错误消息:
'Microsoft.SharePoint.Client.Folder' does not contain a definition for 'ListItemAllFields' and no extension method 'ListItemAllFields' accepting a first argument of type 'Microsoft.SharePoint.Client.Folder' could be found (are you missing a using directive or an assembly reference?)
我有以下项目参考资料
Microsoft.SharePoint.Client
microsoft.SharePoint.Client.Runtime
我有以下使用指令
using SP = Microsoft.SharePoint.Client;
知道我为什么会犯这个错误吗
该应用程序是从桌面环境运行的winform。这是因为SharePoint 2010文件夹API没有ListItemAllFields属性-它是在2013年添加的
可能重复:我提出了一个愚蠢的问题,但在定义文件夹对象时是否必须使用SP.folder,或者编译器是否足够聪明,能够根据调用的函数知道返回类型。