将 .NET Core 控制台应用程序与本地 d365 crm 连接时出错
Error while connecting .NET core console app with d365 crm on-prem
我已经使用客户端 ID、客户端密码和组织 URI 将 d365 CRM 在线连接到 .net 核心控制台应用程序。但是它在与本地连接时抛出错误。
这里是错误。
Microsoft.PowerPlatform.Dataverse.Client.Utils.DataverseConnectionException
HResult=0x80131500
Message=Failed to connect to Dataverse
Source=Microsoft.PowerPlatform.Dataverse.Client
StackTrace:
at Microsoft.PowerPlatform.Dataverse.Client.ServiceClient.CreateServiceConnection(Object externalOrgServiceProxy, AuthenticationType requestedAuthType, String hostName, String port, String orgName, NetworkCredential credential, String userId, SecureString password, String domain, String Geo, String claimsHomeRealm, Boolean useSsl, Boolean useUniqueInstance, OrganizationDetail orgDetail, String clientId, Uri redirectUri, PromptBehavior promptBehavior, OrganizationWebProxyClient externalOrgWebProxyClient, String certificateThumbPrint, StoreName certificateStoreName, X509Certificate2 certificate, Uri instanceUrl, Boolean isCloned, Boolean useDefaultCreds, Version incomingOrgVersion, ILogger externalLogger)
at Microsoft.PowerPlatform.Dataverse.Client.ServiceClient..ctor(Uri instanceUrl, String clientId, String clientSecret, Boolean useUniqueInstance, ILogger logger)
at DOHTestCoreConApp.Program.crmConnection() in C:\DOH PRP\Code\DOHTestCoreConApp\DOHTestCoreConApp\Program.cs:line 23
at DOHTestCoreConApp.Program.Main(String[] args) in C:\DOH PRP\Code\DOHTestCoreConApp\DOHTestCoreConApp\Program.cs:line 11
This exception was originally thrown at this call stack:
[External Code]
Inner Exception 1:
AggregateException: One or more errors occurred. (Need a non-empty authority (Parameter 'Authority'))
Inner Exception 2:
ArgumentNullException: Need a non-empty authority (Parameter 'Authority')
这是代码
string SoapOrgServiceUri = "http://crm/XRMServices/2011/Organization.svc";
Uri serviceUri = new Uri(SoapOrgServiceUri);
string client_id = "****";
string client_sec = "****";
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
var cdsClient = new ServiceClient(serviceUri, client_id, client_sec, true);
On prem 不使用 azure 广告客户端 ID/密码。
您将需要使用广告帐户。
参见 https://docs.microsoft.com/en-us/dynamics365/customerengagement/on-premises/developer/active-directory-claims-based-authentication
我能够使用 Odata 客户端将本地 d365 CRM 与我的 .net 核心应用程序连接起来。
这是 link 到 https://docs.microsoft.com/en-us/odata/client/getting-started
我已经使用客户端 ID、客户端密码和组织 URI 将 d365 CRM 在线连接到 .net 核心控制台应用程序。但是它在与本地连接时抛出错误。
这里是错误。
Microsoft.PowerPlatform.Dataverse.Client.Utils.DataverseConnectionException
HResult=0x80131500
Message=Failed to connect to Dataverse
Source=Microsoft.PowerPlatform.Dataverse.Client
StackTrace:
at Microsoft.PowerPlatform.Dataverse.Client.ServiceClient.CreateServiceConnection(Object externalOrgServiceProxy, AuthenticationType requestedAuthType, String hostName, String port, String orgName, NetworkCredential credential, String userId, SecureString password, String domain, String Geo, String claimsHomeRealm, Boolean useSsl, Boolean useUniqueInstance, OrganizationDetail orgDetail, String clientId, Uri redirectUri, PromptBehavior promptBehavior, OrganizationWebProxyClient externalOrgWebProxyClient, String certificateThumbPrint, StoreName certificateStoreName, X509Certificate2 certificate, Uri instanceUrl, Boolean isCloned, Boolean useDefaultCreds, Version incomingOrgVersion, ILogger externalLogger)
at Microsoft.PowerPlatform.Dataverse.Client.ServiceClient..ctor(Uri instanceUrl, String clientId, String clientSecret, Boolean useUniqueInstance, ILogger logger)
at DOHTestCoreConApp.Program.crmConnection() in C:\DOH PRP\Code\DOHTestCoreConApp\DOHTestCoreConApp\Program.cs:line 23
at DOHTestCoreConApp.Program.Main(String[] args) in C:\DOH PRP\Code\DOHTestCoreConApp\DOHTestCoreConApp\Program.cs:line 11
This exception was originally thrown at this call stack:
[External Code]
Inner Exception 1:
AggregateException: One or more errors occurred. (Need a non-empty authority (Parameter 'Authority'))
Inner Exception 2:
ArgumentNullException: Need a non-empty authority (Parameter 'Authority')
这是代码
string SoapOrgServiceUri = "http://crm/XRMServices/2011/Organization.svc";
Uri serviceUri = new Uri(SoapOrgServiceUri);
string client_id = "****";
string client_sec = "****";
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
var cdsClient = new ServiceClient(serviceUri, client_id, client_sec, true);
On prem 不使用 azure 广告客户端 ID/密码。 您将需要使用广告帐户。 参见 https://docs.microsoft.com/en-us/dynamics365/customerengagement/on-premises/developer/active-directory-claims-based-authentication
我能够使用 Odata 客户端将本地 d365 CRM 与我的 .net 核心应用程序连接起来。 这是 link 到 https://docs.microsoft.com/en-us/odata/client/getting-started