web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

UserLocalizedLabel.Label throws exception

(0) ShareShare
ReportReport
Posted on by 3,634

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);    
}


*This post is locked for comments

I have the same question (0)
  • a33ik Profile Picture
    84,331 Most Valuable Professional on at

    Hello,

    Can you please provide code using which you instantiate service?

  • Mohsin Ali Profile Picture
    3,634 on at

    yes, have a look into following:

    using (OrganizationServiceProxy sp = new OrganizationServiceProxy(orgUrl, null, client, null))

                   {

                       IOrganizationService service = (IOrganizationService)sp;

                       sp.EnableProxyTypes();

    }

  • Mohsin Ali Profile Picture
    3,634 on at

    Now getting exception that the item with same key is already exists.

    Update the exception is removed now but I can see that the relations are also being fetched.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
Varsha deshpande Profile Picture

Varsha deshpande 5

#2
JS-09031509-0 Profile Picture

JS-09031509-0 3

#3
Ciprian  P Profile Picture

Ciprian P 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans