My Code:
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++;
}
I am getting this Error : Method Microsoft.SharePoint.Client.ClientRuntimeContext.Load: type argument 'Microsoft.Online.SharePoint.TenantAdministration.SPOSitePropertiesEnumerable' violates the constraint of type parameter 'T
Is there any other way to retrieve all site collections?
The error:
occurs since there is mismatch between
Microsoft.Online.SharePoint.Client.Tenant.dllassembly and theMicrosoft.SharePoint.Client.dllassembly versions that are referenced in project.Microsoft released the following SDKs:
Microsoft.Online.SharePoint.Client.Tenant.dllassembly version 16 (C:\Program Files\SharePoint Client Components\16.0\Assemblies) is shipped with this SDKMicrosoft.Online.SharePoint.Client.Tenant.dllassembly version 15 (C:\Program Files\SharePoint Client Components\Assemblies) is shipped with this SDKResolution
Ensure the proper version of
Microsoft.Online.SharePoint.Client.Tenant.dllassembly is referenced.For example, for SharePoint Online project the the following assembly should be referenced:
Microsoft.Online.SharePoint.Client.Tenant, Version=16.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c