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)

crmsvcutil.exe generates "UnknownLabel" OptionSets

(0) ShareShare
ReportReport
Posted on by 50

Hi,

we are using currently microsoft crm in germany and the language is also german. I generate all classes with crmsvcutil.exe and it worked fine till i needed to change values for OptionSets in plugins. Somehow when i create a new OptionSet we store the labels in german if crmsvcutil.exe generates classes i get this:

public enum prg_belegstatus

{

[System.Runtime.Serialization.EnumMemberAttribute()]

UnknownLabel100000000 = 100000000,

[System.Runtime.Serialization.EnumMemberAttribute()]

UnknownLabel100000001 = 100000001,

[System.Runtime.Serialization.EnumMemberAttribute()]

UnknownLabel100000002 = 100000002,

[System.Runtime.Serialization.EnumMemberAttribute()]

UnknownLabel100000003 = 100000003,

[System.Runtime.Serialization.EnumMemberAttribute()]

UnknownLabel100000004 = 100000004,

}

Generating classes for the built-in OptionSets is working fine and i get the correct enum classes.

Is there a way that crmsvcutil.exe is using the german labels if the language set to german ?

This is really an annoying bug because i wanted to prevent to hardcode OptionSet values in the code.

Kind Regards

Markus

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Robert Massa Profile Picture
    30 on at

    I had the same problem (except with Dutch labels). You can modify the NamingService.cs in the sample project and recompile to support other languages.

    /// <summary>
    /// Handles building the name for an Option of an OptionSet.
    /// </summary>
    public string GetNameForOption(OptionSetMetadataBase optionSetMetadata, OptionMetadata optionMetadata, IServiceProvider services) {
    string name = string.Empty;
    var stateOptionMetadata = optionMetadata as StateOptionMetadata;
    if (stateOptionMetadata != null) {
    name = stateOptionMetadata.InvariantName;
    }
    else {
    foreach (LocalizedLabel localizedLabel in (Collection<LocalizedLabel>)optionMetadata.Label.LocalizedLabels) {
    if (localizedLabel.LanguageCode == 1033 || localizedLabel.LanguageCode == 1043) // English or Dutch
    name = localizedLabel.Label;
    }
    }

    if (string.IsNullOrEmpty(name)) {
    name = string.Format((IFormatProvider)CultureInfo.InvariantCulture, "UnknownLabel{0}", new object[1] { (object)optionMetadata.Value.Value });
    }

    name = CreateValidName(name);
    name = EnsureValidIdentifier(name);
    name = EnsureUniqueOptionName(optionSetMetadata, name);
    return name;
    }

    private static Regex nameRegex = new Regex("[a-z0-9_]*", RegexOptions.IgnoreCase | RegexOptions.Compiled | RegexOptions.CultureInvariant);
    private static string CreateValidName(string name) {
    string input = name.Replace("$", "CurrencySymbol_").Replace("(", "_");
    var stringBuilder = new StringBuilder();
    for (Match match = NamingService.nameRegex.Match(input); match.Success; match = match.NextMatch())
    stringBuilder.Append(match.Value);
    return ((object)stringBuilder).ToString();
    }

  • Markus Benz Profile Picture
    50 on at

    NamingService.cs ? So i need to recompile the CrmSvcUtil.exe ?

  • Robert Massa Profile Picture
    30 on at

    No, in the SDK is an extension which generates the picklists, you need to make the changes there and recompile.

    SampleCode\CS\CrmSvcUtilExtensions\GeneratePicklistEnums\

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!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans