Error activating features - key cannot be null - redux
A while ago, I posted about a problem deploying declarative XML content types and fields.
Error occurred in deployment step ‘Activate Features’: Key cannot be null. Parameter name: Key
I’ve just encountered the same error - but this time with a field being deployed programmatically - i.e., no XML at all. I was deploying a Managed Metadata field (TaxonomyField) and doing this:
TaxonomyField taxField = web.Fields.CreateNewField("TaxonomyFieldType", "My Field") as TaxonomyField; taxField.SspId = termStore.Id; ...snip... taxField.Update(); web.Fields.Add(taxField);
This seemed pretty reasonable - except for the error, of course. In this case it was caused by taxField.Update() - this is not required - the field doesn’t actually exist at this point.