我的代码:
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:type参数'Microsoft.Online.SharePoint.TenantAdministration.SPOSitePropertiesEnumerable'违反了类型参数'T
的约束还有其他方法可以检索所有网站集吗?
答案 0 :(得分:2)
错误:
方法Microsoft.SharePoint.Client.ClientRuntimeContext.Load:type 争论 &#39; Microsoft.Online.SharePoint.TenantAdministration.SPOSitePropertiesEnumerable&#39; 违反了类型参数&#39; T&#39;。
的约束
因为Microsoft.Online.SharePoint.Client.Tenant.dll
程序集与项目中引用的Microsoft.SharePoint.Client.dll
程序集版本不匹配而发生。
Microsoft发布了以下SDK:
Microsoft.Online.SharePoint.Client.Tenant.dll
汇编版 16 (C:\Program Files\SharePoint Client Components\16.0\Assemblies
)随附此SDK Microsoft.Online.SharePoint.Client.Tenant.dll
汇编版 15 (C:\Program Files\SharePoint Client Components\Assemblies
)随附此SDK 解决强>
确保引用了Microsoft.Online.SharePoint.Client.Tenant.dll
程序集的正确版本。
例如,对于SharePoint Online项目,应引用以下程序集:Microsoft.Online.SharePoint.Client.Tenant, Version=16.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c