I managed to fix it. Recently, the site was upgraded from Umbraco 4.5 to Umbraco 4.7.1, so the dll had to be replaced with later ones. In the older version of Umbraco, the return type was public void AddPropertyType
, while the new public PropertyType AddPropertyType
. Apparently, during the upgrade, the new cms.dll was not copied, so I copied it from a clean Umbraco 4.7.1 solution, changed the code to get the return type, and that helped.
Required Namespaces:
using umbraco.cms.businesslogic.datatype; using umbraco.cms.businesslogic.web;
Thus, the last code (assuming the assembly is correct):
var dt = DocumentType.GetByAlias("TestDocType"); var pType = dt.AddPropertyType(new DataTypeDefinition(-49),"testprop", "test prop");
source share