次の方法で共有


Contenttypebinding, ListUrl and Multi-Lingual Sites

SCENARIO :

You have created a custom site definitions and features to create Custom Site columns, Custom Content types, Binding the custom content type with the “Pages” list, Provisioning of Master Pages and Page Layouts etc.

When you create a top level site collection based on your custom site definition then you encounter “File not found” error – and that only while creating a non-English site.

DETAILS :

You are using a site level Feature to deploy a site content type, and then a web feature to associate that content type to Pages Library. The web scoped feature being something like :

feature.xml:

 <Feature  Id="<Feature GUID>"
          Title="<Feature Title>"
          Description="<Feature Title>"
          Version="12.0.0.0"
          Hidden="FALSE"
          Scope="Web"
          DefaultResourceFile="core"
          xmlns="https://schemas.microsoft.com/sharepoint/">
  <ElementManifests>
    <ElementManifest Location="ContentTypeBinding.xml"/>
  </ElementManifests>
</Feature>

ContentTypeBinding.xml:

 <Elements xmlns="https://schemas.microsoft.com/sharepoint">
<ContentTypeBinding ContentTypeId="0x.........." ListUrl="Pages" />
</Elements>

Now, when creating site collection from Central Admin in, say German Language, using the custom site def, one gets this error :

"The element of type 'ContentTypeBinding' for feature '<Feature Title>' (id: <Feature GUID>) threw an exception during activation: The system cannot find the file specified. (Exception from HRESULT: 0x80070002)"

The same set up works when creating site based on English (1033) locale.

ERROR STACK :

(Exception from HRESULT: 0x80070002)
at Microsoft.SharePoint.Library.SPRequestInternalClass.GetMetadataForUrl(String bstrUrl, Int32 METADATAFLAGS, Guid& pgListId, Int32& plItemId, Int32& plType, Object& pvarFileOrFolder)
at Microsoft.SharePoint.Library.SPRequest.GetMetadataForUrl(String bstrUrl, Int32 METADATAFLAGS, Guid& pgListId, Int32& plItemId, Int32& plType, Object& pvarFileOrFolder)
at Microsoft.SharePoint.SPWeb.GetMetadataForUrl(String relUrl, Int32 mondoProcHint, Guid& listId, Int32& itemId, Int32& typeOfObject, Object& fileOrFolder)
at Microsoft.SharePoint.SPWeb.GetList(String strUrl)
at Microsoft.SharePoint.SPContentTypeBindingElement.EnsureContentTypeExists(SPWeb web)
at Microsoft.SharePoint.SPContentTypeBindingElement.ElementActivated(SPFeaturePropertyCollection props, SPSqlCommand sqlcmdAppendOnly, SPWebApplication webApp, SPSite site, SPWeb web, Boolean fForce)
at Microsoft.SharePoint.Administration.SPElementDefinitionCollection.ProvisionContentTypeAndEventReceiverBindings(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.ProvisionElements(SPFeaturePropertyCollection props, SPWebApplication webapp, SPSite site, SPWeb web, Boolean fForce)
at Microsoft.SharePoint.SPFeature.Activate(SPSite siteParent, SPWeb webParent, SPFeaturePropertyCollection props, Boolean fForce)

CAUSE & RESOLUTION

In Element.xml we can see this :

 <ContentTypeBinding ContentTypeId="0x.........." ListUrl="Pages" />

the ListsUrl property is set to "Pages" but in German it is called "Seiten"... so we should be using $Resources:cmscore,List_Pages_UrlName; as in :

 <ContentTypeBinding ContentTypeId="0x.........." ListUrl="$Resources:cmscore,List_Pages_UrlName;" />

Replacing the ListsUrl property with the Resource will make sure that the right value is picked from the resource file from appropriate location (which in this case will be under 1031- German) ..rather than directly hard-coding Pages url in the Feature.

So, it explains the "File Not Found' error, because it was not able to find "~site/Pages" url. It should be looking for "~site/Seiten" url (in German).Ensuring that we should be looking for the appropriate resource value corrects the error.