我正在尝试使用OrganizationServiceProxy从CRM应用程序检索实体。它可以在我的具有互联网访问权限的DEV服务器上运行,而不能在没有互联网访问权限的测试服务器上运行。
ClientCredentials credential = new ClientCredentials();
credential.UserName.UserName = username;
credential.UserName.Password = password;
Uri uri = new Uri(serviceAddress);
OrganizationServiceProxy proxy = new OrganizationServiceProxy(uri, null, credential, null);
proxy.EnableProxyTypes();
EntityCollection entities = proxy.RetrieveMultiple(new FetchExpression(query));
错误登录测试服务器:
System.ArgumentNullException: Value cannot be null.
Parameter name: identityProvider
at Microsoft.Xrm.Sdk.ClientExceptionHelper.ThrowIfNull(Object parameter, String name)
at Microsoft.Xrm.Sdk.Client.ServiceConfiguration`1.AuthenticateOnlineFederationInternal(AuthenticationCredentials authenticationCredentials)
at Microsoft.Xrm.Sdk.Client.ServiceConfiguration`1.Authenticate(AuthenticationCredentials authenticationCredentials)
at Microsoft.Xrm.Sdk.Client.ServiceProxy`1.AuthenticateOnlineFederation()
at Microsoft.Xrm.Sdk.Client.ServiceProxy`1.AuthenticateCore()
at Microsoft.Xrm.Sdk.Client.ServiceProxy`1.ValidateAuthentication()
at Microsoft.Xrm.Sdk.Client.ServiceContextInitializer`1.Initialize(ServiceProxy`1 proxy)
at Microsoft.Xrm.Sdk.Client.OrganizationServiceProxy.RetrieveMultipleCore(QueryBase query)
答案 0 :(得分:0)
我强烈建议使用CrmServiceClient创建IOrganizationService。 https://docs.microsoft.com/en-us/powerapps/developer/common-data-service/xrm-tooling/sample-simplified-connection-quick-start https://docs.microsoft.com/en-us/powerapps/developer/common-data-service/xrm-tooling/build-windows-client-applications-xrm-tools
答案 1 :(得分:0)
我遇到了同样的问题。防火墙阻止了一些链接。在服务器中允许访问链接后,它起作用了。