SharePoint 2010: GetAvailableWebTemplates CollectionNotInitializedException
The new client object model is something which required some getting used to. Most of the data in the objects isn’t loaded untill you request it, even when calling methods.
For instance, the method GetAvailableWebTemplates returns an object of type WebTemplateCollection. You would probably expect that object to contain all the available web templates on your site, right? Well it doesn’t, untill you’ve explicitely ordered the ClientContext to load that collection. So what you want to do is:
context.Load(coll);
context.ExecuteQuery();
Leave a Comment