我的情况是突然我得到:值不能是信任名称:服务当我尝试获取组织服务时,在谷歌搜索之后,我发现我的项目使用了WS- null.Parameter安全性,这可能会造成我的问题。
在阅读了ms docs后,我发现这可能就是我的情况:
如果您正在访问CrmServiceClient.OrganizationServiceProxy属性:
删除代码中对该属性的所有使用。CrmServiceClient实现了IOrganizationService并公开了组织服务代理的所有可设置内容。
我的问题是,如果我删除我的使用:
CrmServiceClient crmServiceClient = new CrmServiceClient( connectionString);
IOrganizationService organizationService = (IOrganizationService)crmServiceClient.OrganizationWebProxyClient != null
? (IOrganizationService)crmServiceClient.OrganizationWebProxyClient : (IOrganizationService)crmServiceClient.OrganizationServiceProxy;可能的替代品是什么?
有没有人处理过这个案子?有没有其他方法来解决这个问题?
发布于 2020-05-25 20:40:16
您的即时问题可能是由于身份验证问题造成的,例如密码过期。这将导致Service属性为空。您可以在使用返回的客户端之前查看LastCrmError属性,以便检测这种情况。我使用过这样的代码:
Microsoft.Xrm.Tooling.Connector.CrmServiceClient c = new Microsoft.Xrm.Tooling.Connector.CrmServiceClient(connStr);
// At least when using Office365 authentication, invalid (or expired password) will show up in LastCrmError.
// I have not seen LastCrmException, but it sounds bad, too, to check that too.
if (!(string.IsNullOrEmpty(c.LastCrmError) && c.LastCrmException == null))
{
Console.Error.WriteLine(Environment.NewLine + "CRM Error: " + c.LastCrmError);
if (c.LastCrmException != null)
{
Console.Error.WriteLine("CRM Exception: " + c.LastCrmException.Message);
Console.Error.WriteLine("CRM Exception details: " + c.LastCrmException.ToString());
}
Environment.Exit(99);
}当WS-Trust安全性被删除并升级到较新的9.2.xSDK时,此代码可能会停止工作,如Use of Office365 authentication with the WS-Trust security protocol中所述
我想通过只使用来自IOrganizationService接口的方法(见下文)来防止代码的未来,但是CrmLastError在IOrganizationProxy接口中不可用,所以现在我使用上面的代码。但是其余的代码库只依赖于IOrganizationService接口,因此代码的重复工作应该是最少的。
IOrganizationService c = new Microsoft.Xrm.Tooling.Connector.CrmServiceClient(connStr);https://stackoverflow.com/questions/61342765
复制相似问题