不包含 ListItemAllFields 的定义
Does not contain a definition for ListItemAllFields
我有以下代码:
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 年添加的。
可能重复:
我有以下代码:
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 年添加的。
可能重复: