如何修复OrganizationServiceProxy“ System.ArgumentNullException:值不能为空。参数名称:identityProvider”问题

时间:2019-04-09 19:46:00

标签: c# dynamics-crm crm xrm xrmquery

我正在尝试使用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)

2 个答案:

答案 0 :(得分:0)

答案 1 :(得分:0)

我遇到了同样的问题。防火墙阻止了一些链接。在服务器中允许访问链接后,它起作用了。