c# - 无法通过 C# 代码访问 MS CRM Dynamic 365

标签 c# dynamics-crm console-application office365 dynamics-365

我在尝试连接到 MS CRM v9 时遇到问题

我使用此代码进行连接:

Uri organizationUri = new Uri(OrgUrl);
AuthenticationCredentials authCredentials = new AuthenticationCredentials();
authCredentials.ClientCredentials.UserName.UserName = UserName;
authCredentials.ClientCredentials.UserName.Password = Password;
OrganizationServiceProxy organizationProxy = new OrganizationServiceProxy(organizationUri, null, authCredentials.ClientCredentials, null);
organizationProxy.EnableProxyTypes();`
var _service = organizationProxy;

这是异常消息

HResult=-2146233079 Message=Metadata contains a reference that cannot be resolved: 'https://myOrg.api.crm4.dynamics.com/XRMServices/2011/Organization.svc?wsdl&sdkversion=9'. InnerException: HResult=-2146233079 Message=The underlying connection was closed: An unexpected error occurred on a send. InnerException: HResult=-2146232800 Message=Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host. InnerException: ErrorCode=10054 HResult=-2147467259 Message=An existing connection was forcibly closed by the remote host

以前有人遇到过这个问题吗? PS:此代码之前在同一个项目中运行过

最佳答案

您似乎需要将 SDK 引用更新为新的 9.0 SDK 引用。 SDK 不再需要单独下载,您必须使用 NuGet ( https://blogs.msdn.microsoft.com/crm/2017/11/01/whats-new-for-customer-engagement-developer-documentation-in-version-9-0/ )

No more monolithic SDK download Probably the greatest single change is that we are no longer providing a single download package for all the documentation, tools and sample code. Going forward, instead of shipping a single package with everything in it, we will offer an a-la-carte approach so that you can download the individual things as you need them.

Get the assemblies and tools you need. SDK assemblies and tools will be distributed only via NuGet. We will provide a script that will allow you to download the assemblies and tools from NuGet. See Where to find the NuGet SDK packages and Download tools from NuGet.

Self-serve offline content generation. The new learn.microsoft.com site will allow you to download a PDF for any of our content areas so that you can read and search the documentation while offline.

Sample code availability. All our sample code will be available on msdn.microsoft.com or on GitHub. The code.msdn.microsoft.com site is designed for sample code and provides a good experience as well as providing us better metrics on usage.

Download only the pieces you need. Various assets we have included in the download package will be available as individual downloads. This way, if one of the assets needs to be updated we can just update it without releasing the entire SDK package.

https://www.nuget.org/profiles/crmsdk有您可能需要的所有 SDK DLL 的列表。具体https://www.nuget.org/packages/Microsoft.CrmSdk.XrmTooling.CoreAssembly/包括我认为您真正需要的连接器。

您可以在 NuGet 控制台中使用以下命令将其添加到您的项目

Install-Package Microsoft.CrmSdk.XrmTooling.CoreAssembly -Version 9.0.0.7

如果您不需要特定版本,则可以使用

Install-Package Microsoft.CrmSdk.XrmTooling.CoreAssembly

关于c# - 无法通过 C# 代码访问 MS CRM Dynamic 365,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48279259/

相关文章:

c# - Dynamics CRM - 在新创建实体的工作流中访问属性

c# - 为什么要使用 params 关键字

c# - 在 C# 控制台应用程序中显示阿拉伯字符

dynamics-crm-2011 - 客户关系管理 2013 : Calling actions from javascript

c# - 如何通过参数化存储过程填充列表框?

c# - 我应该如何为应用程序实现 OAuth?

c# - 在 Visual Studio 2013 中生成单元测试报告

dynamics-crm - 在家学习动态-crm编程

java - 如何从 Java 应用程序中与 C 控制台应用程序交互

c# - LINQ to Entities不支持指定的类型成员'Offset'