CRM 2015在线OData服务

时间:2016-03-14 22:34:31

标签: c# odata crm dynamics-crm-online dynamics-crm-2015

每个人,

我正在使用sharepoint显示只读crm数据。我按照Develop1.net的指示进行了操作。这意味着我在CRM 2015 SDK中使用了WebAppWalkthrough。这很有效,数据确实出现在我的SharePoint应用程序中。但是,当我生成一个新的xrm.cs文件时,要访问我的自定义文件,我会在浏览器中获得以下内容:

Request Error

我确实在SDK中使用了包含的CrmSvcUtil.exe。我为生成xrm.cs文件而运行的代码是:

CrmSvcUtil.exe
/codeCustomization:"Microsoft.Xrm.Client.CodeGeneration.CodeCustomization, Microsoft.Xrm.Client.CodeGeneration" 
/out:"..\Xrm.cs" 
/url:https://<Org>.api.crm.dynamics.com/XRMServices/2011/Organization.svc 
/username:<user name> 
/password:<password>  
/namespace:Xrm 
/serviceContextName:XrmServiceContext 
/servicecontextprefix:Xrm

这将成功创建一个新的xrm.cs文件,但只要我更新我的解决方案并重建它,我就会在浏览器中收到请求错误。我使用/generateActions标记尝试了上述代码,甚至使用Device Registration Tool注册了我的计算机以获得deviceid and devicepassword。然后我将\deviceid and \devicepassword标志添加到上面的代码中。生成的文件再次没有错误,但只要我将其添加到解决方案中,我就会收到错误信息。

所以我觉得WebAppWalkthrough可能有问题。我再次重新下载了SDK并遇到了同样的问题。所以我决定按照Microsoft的指示从头开始构建OData服务。同样的错误。

我的代码与SDK或Microsoft链接中的代码没有什么不同。我在Visual Studio中没有出现构建错误和错误。

1 个答案:

答案 0 :(得分:0)

通过CrmSvcUtil.exe生成代码的方式似乎存在问题。以下是我最终要做的事情:

1)  I modified the WebAppWalkthrough file.  Basically I just deleted the .aspx pages since I don’t need them.
2)  I deleted the Xrm.cs file that is in the folder.
3)  I created a blank C# class file called Xrm.cs.
4)  I used a tool called XrmToolBox with a plugin called Early Bound Generator
    a.  I was able to create a separate .cs file for each entity including the XrmServiceContext.
5)  I manually copied the code from the opportunity file and the XrmServiceContext file into the blank Xrm.cs file.
6)  Anything that had an error in the new Xrm.cs file was deleted
7)  Added [assembly: Microsoft.Xrm.Sdk.Client.ProxyTypesAssemblyAttribute()] above the namespace.
8)  Added using Microsoft.Xrm.Portal.Web.Data.Services; inside the namespace.