I have a simple Sandbox Solution with a Content Type in it. The Content Type simply inherits from the Item content type. It adds no additional fields to it.
I've added a Feature Resource file to my project and entered one key/value pair for my content type name:
<data name="Ctype1Name" xml:space="preserve">
<value>My Content Type</value>
</data>
I then reference it from my content type definition in the elements file:
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<!-- Parent ContentType: Item (0x01) -->
<ContentType ID="0x01006d8d9c500d1f4f0b9cb80f36f177d7ff"
Name="$Resources:Ctype1Name;"
Group="Custom Content Types"
Description="My Content Type"
Inherits="TRUE"
Version="0">
<FieldRefs>
</FieldRefs>
</ContentType>
</Elements>
When I attempt to activate the feature, either through Visual Studio's Deploy command, or via manual solution deployment (i.e. upload .wsp, activate solution, activate feature), I get an error:
Microsoft.SharePoint.SPInvalidContentTypeNameException: The content type name '$Resources:Ctype1Name;' cannot contain: \ / : * ? " # % < > { } | ~ & , two consecutive periods (..), or special characters such as a tab. at Microsoft.SharePoint.Administration.SPElementDefinitionCollection.ProvisionFieldsAndContentTypes(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(SPFeatureDefinitio...
I've tried recycling the User Code Service, rebooting the machine, etc, and I still get the error. When I change the Solution from a Sandboxed to a Farm Solution, I no longer get the error.
It appears that the feature activation logic is failing to localize the Content Type name, and as a result it is being passed through with the RESX reference (i.e. "$Resources:Ctype1Name;") all the way through, which violates the content type naming.
Oddly, when I use localized strings in my Feature Name/Description, or in a Site Column's Display Name, things work just fine. I am only having the problem with Content Types at the moment (not to say other elements won't work quite right, I just haven't tested them). For example the following provisions just fine:
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<Field
ID="{ce45f1c9-e76d-41fb-abb6-253aa7538ae8}"
Name="MySitecol"
DisplayName="$Resources:MySiteColumnName"
Type="Text"
Required="FALSE"
Group="Custom Site Columns">
</Field>
</Elements>
Can anyone confirm this is an issue and maybe point me to any resources indicating such?
Thanks!
Update: Given that I experienced this issue with a manual .wsp deployment, I wasn't expecting different results, but I also tried with Visual Studio 11 Beta and I get the same experience.
I am running SharePoint Server 2010 Enterprise. I think I'm running RTM. In Central Admin, my version numbers are listed as: 14.0.4763.1000 (it's a dev server/farm). I have since upgraded to SP1 + December 2012 CU and still having the issue.