Wednesday, August 26, 2009

NullReferenceException: Microsoft.Crm.ObjectModel.OrganizationUIService.LabelLoaderPublished.LoadMetadataLabel

WARNING: Back up your CRM database if you decide to follow the steps below!

If you see the following error in the CRM trace/log file (as I did today on a VPC… for no apparent reason):

Stack Trace Info: [NullReferenceException: Object reference not set to an instance of an object.]
at Microsoft.Crm.ObjectModel.OrganizationUIService.LabelLoaderPublished.LoadMetadataLabel(Int32 entityType, String attributeName, ExecutionContext context)


The problem might be that there’s an old attribute being referenced in the entity’s form. To determine this and remove the bad form from the form's xml definition, open the OrganizationUIBase table and look for the object type id for the problem entity (e.g., 10016). Copy the FormXml to notepad and save the file with an xml extension. Open the file in IE or other xml viewer/editor and look for an attribute that no longer exists. In notepad or in your xml editor, remove the problematic node, copy the new xml, and paste it into the FormXml in the OrganizationUIBase table. Restart IIS and then see if you can now export, publish, or do other work with the entity.

Of course, any direct change to the CRM database is not supported by Microsoft and should only be done as a last resort. Since I was working on a non-production VPC I went ahead and made the change... and it did the trick. Again, I have no idea how the problem occurred. The problem entity was fine the last time I loaded the VPC and today I couldn't publish, remove attributes, or export. Strange, very strange.

-Tim

1 comment:

  1. I had this exact same error on a preproduction system and came across your post after basically a day of troubleshooting. Thanks alot. One note is that there's a less tedious way to change this than editing the database. Open up the entity form and make an insignificant change (change a random label). Then save and you should be able to publish. That way you aren't going off into unsupported land.

    ReplyDelete