集成微软动态CRM 2011 [英] Integration to Microsoft Dynamic CRM 2011
问题描述
如何使用CRM 2011 SDK和C#
How to Integrate your application to Microsoft CRM 2011 using CRM 2011 SDK and C#?
编辑应用程序集成到Microsoft CRM 2011:
我提出我的问题的答案跟随问题和答案格式。根据圭多Preite。
I moved my question to the answer to follow the question and answer format. according to Guido Preite.
推荐答案
由于我在分享新的东西,我每天学习的习惯,现在我,我只是要在这里展示我如何连接到Microsoft CRM 2011采用CRM 2011 SDK和C#。这将帮助你不要在墙上碰你的头就像我做了,而以前。
Because I'm now in a habit of sharing new things I learn everyday, I'm just gonna show here how I connected to Microsoft CRM 2011 using CRM 2011 SDK and C#. This will help you not to bang your head on the wall like I did a while ago.
首先引用添加到您的项目到Microsoft.Xrm.Sdk.dll 。您可以从CRM 2011 SDK获得(在这里下载: HTTP :?//www.microsoft.com/en-us/download/details.aspx ID = 24004 )
First add a reference to your project to the Microsoft.Xrm.Sdk.dll. which you can get from the CRM 2011 sdk(download it here: http://www.microsoft.com/en-us/download/details.aspx?id=24004).
下面是关于代码如何连接到CRM服务:
here is the code on how to connect to the CRM Service:
using Microsoft.Xrm.Sdk.Client;
using Microsoft.Xrm.Sdk.Query;
using Microsoft.Xrm.Sdk;
//This is your Organization Service which you can find from the actual CRM UI. go to Settings>Customizations>Developer Resources.
Uri organizationUri = new Uri("http://crmservername/organizationname/XRMServices/2011/Organization.svc");
Uri homeRealmUri = null;
ClientCredentials credentials = new ClientCredentials();
//Instantiate your network credential that will access the CRM Server
credentials.Windows.ClientCredential = new System.Net.NetworkCredential("username", "password", "domain");
OrganizationServiceProxy orgProxy = new OrganizationServiceProxy(organizationUri, homeRealmUri, credentials, null);
//Instantiate IOrganizationService so you can call the CRM service methods.
IOrganizationService _service = (IOrganizationService)orgProxy
//from this you can now perform CRUD to your CRM.
//I'm just going to provide some example on how to query your entities in CRM like so:
QueryExpression query = new QueryExpression() { };
query.EntityName = "country";
query.ColumnSet = new ColumnSet("name", "2digitiso", "3digitiso");
EntityCollection retrieved = _service.RetrieveMultiple(query);
foreach (var item in retrieved.Entities)
{
MessageBox.Show(item["name"].ToString() + " " + item["2digitiso"].ToString() + " " + item["3digitiso"].ToString());
}
参考:
的 http://nishantrana.wordpress.com/2010/11/03/示例代码换用-iorganizationservice-在CRM-2011 /
的 http://msdn.microsoft.com/en-us/library/gg334708.aspx
的 http://msdn.microsoft.com/en-us/library/gg328149.aspx
http://www.codeproject.com /文章/ 559599 /集成 - 您的应用程序与 - MS-CRM,在线
在,如果你碰巧遇到这样的异常增加:
In Addition if you happen to encounter a exception like this:
CRM Service Exception: Could not load file or assembly 'Microsoft.IdentityModel, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies
安装:Windows标识基础(的 http://www.microsoft.com/en-us/download/details.aspx?id=17331 )
Install : Windows Identity Foundation (http://www.microsoft.com/en-us/download/details.aspx?id=17331)
我希望我帮你们中的一些与您的项目。
I hope I helped some of you with your project.
这篇关于集成微软动态CRM 2011的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!