问题:
我正在使用Microsoft Dynamics CRM 2011
. 我在我们的 CRM 中添加了一个扩展(客户服务联系人)。
我还需要对 UI 进行一些相应的更改。为此,我从XRM.cs 的重新生成开始了我的更改。
作为其中的一部分,我已经完成了以下工作:
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
这帮助我重新生成了Xrm003.cs
. 但是,当我将这个新生成的 Xrm003.cs 与已经存在的 Xrm003.cs 进行比较时,我可以看到一些我根本没有接触过的实体的差异。
以下是其中一些:
原来的有:
/// <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");
}
}
新的有:
/// <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);
}
}
如果您注意到差异,您将看到两件事:
类型
AccountCategoryCode
是Microsoft.Xrm.Sdk.OptionSetValue
(在原始中)和System.Nullable<int>
在重新生成的。方法
set
是执行的。
这也适用于许多其他实体。
谁能告诉我为什么这是因为或者我错过了 XRM.cs 再生的任何步骤?提前致谢!
编辑:一件事,可能是原因(?)是:我们在这 2 个 XRM.cs 之间将 Rollup 16 应用于 CRM。
解决问题的解决方案:
请参考 Daryl 的回答,我已将其标记为答案。
我按照他所说的对我的 XRM.cs 重新生成命令进行了如下更改(以下是适当的命令,它帮助我解决了我的问题):
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
结论:
我的命令中有以下内容,这导致了我在 Q 中提到的问题:
/codeCustomization:"Microsoft.Xrm.Client.CodeGeneration.CodeCustomization,
Microsoft.Xrm.Client.CodeGeneration"
我的问题只是通过删除它来解决。