Monday, October 22, 2012

Microsoft.Crm.LocatorService Exception when Installing UR10 or UR11 on Client

When installing update Rollup 10 or Rollup 11 for your Microsoft Outlook CRM Client, you can come across this error:

“The type initializer for 'Microsoft.Crm.LocatorService' threw an exception.
Cannot load Counter Name data because an invalid index '' was read from the registry.”

This is not a bug in the rollups, it’s the pointers to the performance counters that are corrupted on your computer and they must be rebuilt.


1. Go to Start, write ”cmd”.

2. Right click on cmd.exe and choose ‘Run as administrator’.

3. Write “lodctr /r” and press enter.


You will then get the message ‘Info: Successfully rebuilt performance counter setting from system backup store’.

4. Check if there are providers that are disabled, write “lodctr /q” and press enter


5. You will then get a long list of providers, make sure that the [CRM Client] is Enabled, se below


If not, write “lodctr /e:CRM Client” and press enter.


6. Install the Outlook client rollup, 10(v2) or 11.


Thursday, October 4, 2012

Get Linked Entities Attributes in Plugins

Somehow, I have always managed with QueryExpressions in my plugins. I have never (!!) used FetchXML to get data in plugins before, only in JavaScript.
One really nice thing you can do with FetchExpression, that you can’t with QueryExpression, is to get a linked entity’s attributes in the response. Sweet.

Here’s a simple code example on how to do this
 EntityCollection entityColl = new EntityCollection();
 FetchExpression fetchEx = new FetchExpression(
        @"<fetch mapping='logical'>
                    <entity name='new_contract'>
                         <attribute name='new_name' />                                  
                         <attribute name='new_contract_number' />
                                   <condition attribute='statecode' operator='eq' value='0' />
                                 <link-entity name='contact' from='contactid' to='new_contact_id'>
                                             <attribute name='emailaddress1' />
 entityColl = serviceProxy.RetrieveMultiple(fetchEx);
 if(entityColl.Entities.Count > 0)
         string contractName =  entityColl.Entities[0].Attributes["new_name"].ToString();
         string contractNumber = entityColl.Entities[0].Attributes["new_contract_number"].ToString();
         AliasedValue aliasedContactEmail = (AliasedValue)entityColl.Entities[0].Attributes["new_contract1.firstname"];
         string contactEmailAddress = aliasedContactEmail.Value.ToString();
         //Do something useful with the result