Quantcast
Channel: Microsoft Dynamics CRM Forum - Recent Threads
Viewing all articles
Browse latest Browse all 46379

UserLocalizedLabel.Label throws exception

$
0
0

From following snippet I am adding Display Name as key and Logical name as value to a dictionary. In first iteration of loop it runs successfully but in second iteration it throws exception that Object reference not set to an instance of an object.. Don't know about such weired behavior of this property. any suggestion

Dictionary<string, string> attrData = new Dictionary<string, string>();
RetrieveAllEntitiesRequest metaDataReq = new RetrieveAllEntitiesRequest();
RetrieveAllEntitiesResponse metaDataRes = new RetrieveAllEntitiesResponse();
metaDataReq.EntityFilters = EntityFilters.Entity;

metaDataRes = (RetrieveAllEntitiesResponse)service.Execute(metaDataReq);
EntityMetadata[] emData = metaDataRes.EntityMetadata;
if (emData.Length <= 0)
{
    return;
}
string temp = string.Empty;
//key, value
for (int item = 0; item < emData.Length; item++)
{
    attrData.Add(Convert.ToString(emData[item].DisplayName.UserLocalizedLabel.Label), emData[item].LogicalName);
}



Viewing all articles
Browse latest Browse all 46379

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>