我以这种方式使用CrmSvUtil:

crmsvcutil.exe /url:http://crm2011/MyTestOrg/XRMServices/2011/Organization.svc /out:GeneratedCode.cs /namespace:Xrm /serviceContextName:XrmDataContext

输出包含数千个业务对象和此上下文类:
[System.CodeDom.Compiler.GeneratedCodeAttribute("CrmSvcUtil", "5.0.9688.1533")]
public partial class XrmDataContext : Microsoft.Xrm.Sdk.Client.OrganizationServiceContext

但是查看示例(即。\sdk\walkthroughs\portal\consoleappwalkthrough),我可以清楚地看到那里的上下文类应该从OrganizationServiceContext-> CrmOrganizationServiceContext的更强大的子类派生而来:
[System.CodeDom.Compiler.GeneratedCodeAttribute("CrmSvcUtil", "5.0.9688.583")]
public partial class XrmServiceContext : Microsoft.Xrm.Client.CrmOrganizationServiceContext

我绝对需要CrmOrganizationServiceContext,因为只有那时我才有了我需要的构造函数。所以我做错了什么,或者我错过了哪个设置?

最佳答案

查看该SDK示例的web version给定的参数。他们将生成您要查找的类(class)。

CrmSvcUtil.exe /codeCustomization:"Microsoft.Xrm.Client.CodeGeneration.CodeCustomization, Microsoft.Xrm.Client.CodeGeneration" /out:Xrm\Xrm.cs /url:http://Crm/Contoso/XRMServices/2011/Organization.svc /domain:CONTOSO /username:administrator /password:pass@word1 /namespace:Xrm /serviceContextName:XrmServiceContext

10-05 23:46