【问题标题】:How to get all Site Collections using C# CSOM如何使用 C# CSOM 获取所有网站集
【发布时间】:2014-10-29 10:41:07
【问题描述】:

我的代码:

                SPOSitePropertiesEnumerable spp = null;
                Microsoft.Online.SharePoint.TenantAdministration.Tenant tenant = new Tenant(clientContext);
                int startIndex = 0;

                while (spp == null || spp.Count > 0)
                {
                    spp = tenant.GetSiteProperties(startIndex, true);
                    clientContext.Load(spp);
                    clientContext.ExecuteQuery();

                    foreach (SiteProperties sp in spp)
                    {
                        Response.Write("<br/> All Sites Collection: " + sp.Title + "<br/>");
                       // siteCols.Add(new SiteCol(sp.Title, sp.Url));

                      //  startIndex = siteCols.Count;
                    }
                    startIndex++;
                }

我收到此错误:方法 Microsoft.SharePoint.Client.ClientRuntimeContext.Load:类型参数“Microsoft.Online.SharePoint.TenantAdministration.SPOSitePropertiesEnumerable”违反类型参数“T”的约束

还有其他方法可以检索所有网站集吗?

【问题讨论】:

  • 我尝试了 clientContext.Web.Webs,但我得到了子站点名称。我想要网站集标题。

标签: c# csom sitecollection


【解决方案1】:

错误:

方法 Microsoft.SharePoint.Client.ClientRuntimeContext.Load:类型 争论 'Microsoft.Online.SharePoint.TenantAdministration.SPOSitePropertiesEnumerable' 违反类型参数'T'的约束。

由于Microsoft.Online.SharePoint.Client.Tenant.dll 程序集与项目中引用的Microsoft.SharePoint.Client.dll 程序集版本不匹配而发生。

Microsoft 发布了以下 SDK:

分辨率

确保引用了正确版本的 Microsoft.Online.SharePoint.Client.Tenant.dll 程序集。

例如,对于 SharePoint Online 项目,应引用以下程序集:Microsoft.Online.SharePoint.Client.Tenant, Version=16.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c

【讨论】:

    【解决方案2】:

    类型(see):

    Install-Package Microsoft.Sharepoint.2013.Client.16
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-06-22
      • 2017-11-08
      • 1970-01-01
      • 1970-01-01
      • 2023-03-03
      相关资源
      最近更新 更多