I want to programmatically create a site using custom web templates in sharepoint 2010.
In 2007 I used to get a
SPWebTemplate template = site.GetCustomWebTemplates(LCID)[number];
and used this SPWebTemplate in
SPWeb newSite = web.Webs.Add(url, title, description, LCID, template, true, false);
This worked quite well for 2007. But in 2010 the site templates are saved into the solution store
SPSite.Solutions
which only returns SPUserSolution objects and not SPWebTemplates.
So my question is: How can I programmatically create sites using the site templates from the solution store.
UPDATE: I tried to use
SPWeb newSite = web.Webs.Add(url, title, desc, LCID, templateName, true, false);
where templateName is a string like '{Template-GUID}#TemplateName', but it still does not work. It throws the following error:
Critical error: File or arguments not valid for site template '{4a2d8952-a0af-49a6-8f55-46a59c8d68a2}#CustomerSiteTemplate'. Parameter name: WebTemplate
Any other ideas how to create a site based on a SPWebTemplate?