Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

UserLocalizedLabel.Label throws exception

Posted on by 3,610

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

  • Mohsin Ali Profile Picture
    Mohsin Ali 3,610 on at
    RE: UserLocalizedLabel.Label throws exception

    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.

  • Mohsin Ali Profile Picture
    Mohsin Ali 3,610 on at
    RE: UserLocalizedLabel.Label throws exception

    yes, have a look into following:

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

                   {

                       IOrganizationService service = (IOrganizationService)sp;

                       sp.EnableProxyTypes();

    }

  • a33ik Profile Picture
    a33ik 84,323 Most Valuable Professional on at
    RE: UserLocalizedLabel.Label throws exception

    Hello,

    Can you please provide code using which you instantiate service?

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans