CRM Dynamics IOrOrganizationService SOAP使用最新SDK执行失败

CRM Dynamics IOrOrganizationService SOAP使用最新SDK执行失败,soap,dynamics-365,Soap,Dynamics 365,我一直在使用最新的Xrm sdk访问我公司的dynamics 365帐户的元数据。这已经运行了一段时间,但大约在3周前突然中断。没有代码更改。这只意味着他们这边发生了一些变化 下面是使用过的代码,非常简单。到目前为止,我得到的唯一信息是,他们的安全协议已更改为Tls12,因此在创建Organization Service对象之前尝试设置该信息 ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; 但这也没有影响

我一直在使用最新的Xrm sdk访问我公司的dynamics 365帐户的元数据。这已经运行了一段时间,但大约在3周前突然中断。没有代码更改。这只意味着他们这边发生了一些变化

下面是使用过的代码,非常简单。到目前为止,我得到的唯一信息是,他们的安全协议已更改为Tls12,因此在创建Organization Service对象之前尝试设置该信息

  ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
但这也没有影响

        var sc = ServiceConfigurationFactory.CreateConfiguration<IOrganizationService>(new Uri("soap-url-from-365-developer-resources"));
        var cc = new ClientCredentials();
        cc.UserName.UserName = "username";
        cc.UserName.Password = "password";
        var organizationServiceProxy = new OrganizationServiceProxy(sc, cc);
        organizationServiceProxy.EnableProxyTypes();
        RetrieveAllEntitiesRequest request = new RetrieveAllEntitiesRequest()
        {
            EntityFilters = EntityFilters.Attributes,
            RetrieveAsIfPublished = true
        };

        try
        {

            using (var organizationServiceContext = new CrmOrganizationServiceContext(organizationServiceProxy))
            {
                RetrieveAllEntitiesResponse response = (RetrieveAllEntitiesResponse)organizationServiceContext.Execute(request);
                var entities = response.EntityMetadata
                                       .Where(x => x.DisplayName.UserLocalizedLabel != null &&
                                                   !string.IsNullOrWhiteSpace(x.DisplayName.UserLocalizedLabel.Label)
                                              )
                                       .ToList();
            }
        }
        catch (Exception ex)
        {
            Console.WriteLine("GetAllEntities {0}", ex.Message);            }

我已经尝试了谷歌搜索这个错误消息的所有方法,但都是徒劳的。因此,非常感谢您为解决此问题提供的任何帮助

在过去一年中,SDK兼容性发生了很多变化

您需要确保您拥有与.Net Framework和CRM版本相匹配的正确SDK版本

随着Azure访问控制服务(ACS)的弃用,我们必须 通过删除对ACS的所有引用来修改我们的SDK身份验证代码。 自版本Microsoft Dynamics CRM Online 2016更新1起生效 (v8.1.1)和Microsoft Dynamics 365(v8.2),我们删除了Live ID支持 和服务器端的ACS依赖关系

我们还从CRM 2016(8.x)SDK中删除了Microsoft.Xrm.Client 客户端,因为它不符合OAuth更改,以及 将其替换为Microsoft.Xrm.Tooling.Connector。你可以使用 当前的Microsoft Dynamics 365软件开发工具包(SDK)到 将Microsoft Dynamics CRM访问回6.x版以进行身份验证和 信息

升级到Dynamics 365时,请确保使用最新的Microsoft Dynamics 365软件开发工具包(SDK)。以下概述 其他SDK客户端当前支持的矩阵:


非常感谢,我想关键在于使用Microsoft.Xrm.Tooling.Connector。这会在通过nuget安装时添加其他DLL,我们需要添加ServicePointManager.SecurityProtocol=SecurityProtocolType.Tls12;在CrmServiceClient实例化之前。这就解决了问题。@SrivathsaHarishVenkataramana;为了实现它的价值,我从未添加过
ServicePointManager.SecurityProtocol=SecurityProtocolType.Tls12
,这样您就可以删除它了
System.InvalidOperationException: Metadata contains a reference that cannot be resolved: 'https://macfar.crm4.dynamics.com/XRMServices/2011/Organization.svc?wsdl&sdkversion=9'. ---> System.Net.WebException: The underlying connection was closed: An unexpected error occurred on a send. ---> System.IO.IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host. ---> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host
at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
--- End of inner exception stack trace ---
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
at System.Net.FixedSizeReader.ReadPacket(Byte[] buffer, Int32 offset, Int32 count)
at System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.CheckCompletionBeforeNextReceive(ProtocolToken message, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.ForceAuthentication(Boolean receiveFirst, Byte[] buffer, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.ProcessAuthentication(LazyAsyncResult lazyResult)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Net.TlsStream.ProcessAuthentication(LazyAsyncResult result)
at System.Net.TlsStream.Write(Byte[] buffer, Int32 offset, Int32 size)
at System.Net.ConnectStream.WriteHeaders(Boolean async)
--- End of inner exception stack trace ---
at System.Net.HttpWebRequest.GetResponse()
at  System.ServiceModel.Description.MetadataExchangeClient.MetadataLocationRetriever.DownloadMetadata(TimeoutHelper timeoutHelper)
at System.ServiceModel.Description.MetadataExchangeClient.MetadataRetriever.Retrieve(TimeoutHelper timeoutHelper)
--- End of inner exception stack trace ---
at System.ServiceModel.Description.MetadataExchangeClient.MetadataRetriever.Retrieve(TimeoutHelper timeoutHelper)
at System.ServiceModel.Description.MetadataExchangeClient.ResolveNext(ResolveCallState resolveCallState)
at System.ServiceModel.Description.MetadataExchangeClient.GetMetadata(MetadataRetriever retriever)
at Microsoft.Xrm.Sdk.Client.ServiceMetadataUtility.RetrieveServiceEndpointMetadata(Type contractType, Uri serviceUri, Boolean checkForSecondary)
at Microsoft.Xrm.Sdk.Client.ServiceConfiguration`1..ctor(Uri serviceUri, Boolean checkForSecondary)
at Microsoft.Xrm.Sdk.Client.OrganizationServiceConfiguration..ctor(Uri serviceUri, Boolean enableProxyTypes, Assembly assembly)
at Microsoft.Xrm.Sdk.Client.ServiceConfigurationFactory.CreateConfiguration[TService](Uri serviceUri, Boolean enableProxyTypes, Assembly assembly)
at Microsoft.Xrm.Sdk.Client.ServiceProxy`1..ctor(Uri uri, Uri homeRealmUri, ClientCredentials clientCredentials, ClientCredentials deviceCredentials)