Search code examples
.netdynamics-crm-2011dynamics-crmcode-generationxrm

Issue after regenerating xrm.cs


ISSUE:

I am using Microsoft Dynamics CRM 2011. I have added an extension (Customer Service Contacts) to our CRM.

I need to make some respective changes to UI as well. For that, I started my changes with regeneration of XRM.cs.

I have done following as a part of that:

C:\Users\<userName>\SDK\Bin>CrmSvcUtil.exe 
/codeCustomization:"Microsoft.Xrm.Client.CodeGeneration.CodeCustomization,    
Microsoft.Xrm.Client.CodeGeneration" /out:\Xrm003.cs 
/url:http://<url_for_server>/<organization_name>/XRMServices/2011/Organization.svc
/domain:"<domain_name>" /username:"<username>" /password:"<password>" 
/namespace:<desired_namespace_name> /serviceContextName:XrmServiceContext

This helped me regenerate the Xrm003.cs. But, when I am comparing this newly generated Xrm003.cs with the already existing one, I can see some differences in the entities which I have not touched at all.

Following are some of those:

Original one had:

    /// <summary>
    /// Drop-down list for selecting the category of the account.
    /// </summary>
    [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("accountcategorycode")]
    public Microsoft.Xrm.Sdk.OptionSetValue AccountCategoryCode
    {
        get
        {
            return this.GetAttributeValue<Microsoft.Xrm.Sdk.OptionSetValue>("accountcategorycode");
        }
        set
        {
            this.OnPropertyChanging("AccountCategoryCode");
            this.SetAttributeValue("accountcategorycode", value);
            this.OnPropertyChanged("AccountCategoryCode");
        }
    }

The new one has:

    /// <summary>
    /// Drop-down list for selecting the category of the account.
    /// </summary>
    [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("accountcategorycode")]
    public System.Nullable<int> AccountCategoryCode
    {
        get
        {
            return this.GetAttributeValue<System.Nullable<int>>("accountcategorycode");
        }
        set
        {
            this.SetAttributeValue<Microsoft.Xrm.Sdk.OptionSetValue>("AccountCategoryCode", "accountcategorycode", value);
        }
    }

If you notice the differences, you will see 2 things:

  1. Type of AccountCategoryCode is Microsoft.Xrm.Sdk.OptionSetValue (in the original) and System.Nullable<int> in the regenerated.

  2. The way set is implemented.

This is for many other entities as well.

Can anyone please let me know why is this because of or have I missed any step in regeneration of XRM.cs? Thanks in advance!

EDIT: One thing, which might be the cause(?) is: We had applied Rollup 16 to CRM inbetween these 2 XRM.cs.


SOLUTION TO RESOLVE ISSUE:

Please refer answer by Daryl, which I have marked as an answer.

I followed what he said and did changes to my XRM.cs regeneration command as follows (following one is the appropriate command, which helped me to resolve my issue):

C:\Users\<userName>\SDK\Bin>CrmSvcUtil.exe 
/out:\Xrm003.cs 
/url:http://<url_for_server>/<organization_name>/XRMServices/2011/Organization.svc
/domain:"<domain_name>" /username:"<username>" /password:"<password>" 
/namespace:<desired_namespace_name> /serviceContextName:XrmServiceContext

Conclusion:

I had following in my command which was causing issue that I have mentioned in my Q:

/codeCustomization:"Microsoft.Xrm.Client.CodeGeneration.CodeCustomization,    
Microsoft.Xrm.Client.CodeGeneration"

My issue was resolved just by removing it.


Solution

  • You have some custom code generation in there with whatever "Microsoft.Xrm.Client.CodeGeneration.CodeCustomization,Microsoft.Xrm.Client.CodeGeneration" is. I'm guessing this is what has changed. It almost looks like this has been changed to run in Windows RT, since it doesn't support the property changing events.

    Have you tried the EarlyBound Generator?