I tried programmatically create site from web template. Locale of site is 1029 and sharepoint server is also only in 1029 (without 1033 language pack). During activation of site features (specially pro ProvisioningFeature) installation failed on error:
MESSAGE: ERROR during activation of feature 'ControlledDocumentation.cs-czWebTemplate;FeatureDefinition/6f9864c0-1c33-4425-ba2c-23e59ebd3e1b;6f9864c0-1c33-4425-ba2c-23e59ebd3e1b'.
EXCEPTION MESSAGE: The SPWebTemplate named STS#1 cannot be found. The SPWebTemplate matching the BaseTemplateName and BaseConfigurationID of the WebTemplate declared by feature {6f9864c0-1c33-4425-ba2c-23e59ebd3e1b} could not be found.
EXCEPTION SOURCE: Microsoft.SharePoint
EXCEPTION STACKTRACE: at Microsoft.SharePoint.Administration.SPElementDefinitionCollection.ProvisionWebTemplate(SPFeaturePropertyCollection props, SPSite site, SPWeb web, Boolean fForce)
at Microsoft.SharePoint.Administration.SPElementDefinitionCollection.ProvisionElements(SPFeaturePropertyCollection props, SPWebApplication webapp, SPSite site, SPWeb web, Boolean fForce)
at Microsoft.SharePoint.SPFeature.Activate(SPSite siteParent, SPWeb webParent, SPFeaturePropertyCollection props, Boolean fForce)
at Microsoft.SharePoint.SPFeatureCollection.AddInternal(SPFeatureDefinition featdef, Version version, SPFeaturePropertyCollection properties, Boolean force, Boolean fMarkOnly)
at Microsoft.SharePoint.SPFeatureCollection.AddInternalWithName(Guid featureId, String featureName, Version version, SPFeaturePropertyCollection properties, Boolean force, Boolean fMarkOnly, SPFeatureDefinitionScope featdefScope)
at Microsoft.SharePoint.SPFeatureCollection.Add(Guid featureId, Boolean force, SPFeatureDefinitionScope featdefScope)
at CDl.RD.CreateWeb.TemplateManager.EnsureSiteCollectionFeaturesActivated(SPUserSolution solution, SPSite site) in C:\vyvoj-rp\Řízená dokumentace\v05\RD5-branch\Deployment\SharePointSolutionInstaller\Source\CreateWebControl\TemplateManager.cs:line 85
Reflector showed me a body of method ProvisionWebTemplate:
private void ProvisionWebTemplate(SPFeaturePropertyCollection props, SPSite site, SPWeb web, bool fForce)
{
foreach (SPElementDefinition definition in (IEnumerable) this)
{
if (definition is SPWebTemplateElement)
{
try
{
definition.ElementActivated(props, null, null, site, web, fForce);
continue;
}
catch (Exception exception)
{
ULS.SendTraceTag(0x636e356f, ULSCat.msoulscat_WSS_FeaturesInfrastructure, ULSTraceLevel.High, "{0}", new object[] { string.Format(CultureInfo.InvariantCulture, "The element{0} of type '{1}' for feature '{2}' (id: {3}) threw an exception during activation: {4}", new object[] { (definition.Id != null) ? (" '" + definition.Id + "'") : null, definition.ElementType, this.ParentFeatureDefinition.DisplayName, this.ParentFeatureDefinition.Id, exception.Message }) });
props.Feature.HandleProvisioningException(exception, fForce);
continue;
}
}
}
}
And in ULS log I found repeated row…
No webtemp*.xml files found for language 1033 and product version X.
When I copyied file from ..\14\TEMPLATE\1029\XML\WEBTEMP.XML to ..\14\TEMPLATE\1033\XML\WEBTEMP.XML installation was successfully.
But this is not a solution of our problem.
Solution is using right EnsureSiteCollectionFeaturesActivated method …
private static void EnsureSiteCollectionFeaturesActivated(SPUserSolution solution, SPSite site)
{
if (solution.HasAssemblies && !SPUserCodeService.Local.IsEnabled)
{
throw new InvalidOperationException(SPResource.GetString("ActivatingSolutionFailedUserCodeServiceNotRunning", new object[0]));
}
foreach (SPFeatureDefinition definition in GetFeatureDefinitionsInSolution(solution, site))
{
try
{
if (((definition.Scope == SPFeatureScope.Site) && definition.ActivateOnDefault) && (site.Features[definition.Id] == null))
{
// ULS.SendTraceTag(0x3835646c, ULSCat.msoulscat_WSS_General, ULSTraceLevel.Verbose, string.Format(CultureInfo.InvariantCulture, "activating feature {0}", new object[] { definition.FeatureId }));
site.Features.Add(definition.Id, true, SPFeatureDefinitionScope.Site); // must be force to true !!!
}
}
catch (Exception e)
{
// log - string.Format("ERROR during activation of feature '{0};{1};{2}'. {3}", definition.DisplayName, definition.Name, definition.Id, e.ToString());
}
}
}
Good find!
The reason you get this error is because of the way SharePoint checks for LCID:
In Microsoft.SharePoint.SPWebTemplateElement.ValidateBaseTemplate() (and probably in other places) they check for LCID in the following manner:
uint lCID = (uint) Thread.CurrentThread.CurrentUICulture.LCID;
So this boils down to, that if you have a server that is installed with US regional settings and as you do install a Czech version only of SharePoint, you will get this error.
I get this when activating Web Template features in code/PowerShell/VS2010. A workaround is to use -Force as you describe. Activating the feature using GUI also works.