Error deploying ContentType with FieldRefs

Another Problem-Solution post, and this time it’s going to be quick on a problem you may face deploying a SharePoint feature in Visual Studio.

The error this time states: “Error occurred in deployment step ‘Activate Features’: Key cannot be null. Parameter name: key”.

Again, the error here is not descriptive and doesn’t give us a clue on what the problem is. What will help us is using the output window in Visual Studio to track where the problem occurred (I followed this technique and applied it to workflows in Nintex to troubleshoot problems there, view this post to know more about troubleshooting Workflows).

So the output in Visual Studio provides us with a step by step details on the deployment process, in my case the deployment errored on activating a feature that included only content types, so I know where to investigate now.

What I noticed in my xml that deploys the content type, is that there is a specific content type that references the fields this way:

<FieldRef ID=”{9EDAB26E-CC44-4027-AB05-CB44EA3A6F72}Name=”EmployerName“/>

<FieldRef ID=”{8406B0D9-9302-4BCD-917A-404558F3C9A0}Name=”CustomerFullName” />

<FieldRef ID=”{395B72D8-90D8-4A68-ACDC-C423B205B276}”  Name=”CustomerFeedback” ></ FieldRef>

The way that the CustomerFeedback field was deployed was different than the others, as you can notice it has a separate tag as the ending tag, and the deployment process expects that something has to be inside this field reference, but there is nothing, so it throws the given error.

Conclusion: When referencing FieldRef inside ContentType project item, make sure you don’t have a separate closing tag for the FieldRef.

Hope this little quick tip would help someone out there!

One thought on “Error deploying ContentType with FieldRefs

Leave a Reply

Your email address will not be published. Required fields are marked *