我正在使用Windows应用程序连接Microsoft Dynamics CRM。在这里,我可以使用联机联盟和内部部署类型登录,但是当我尝试使用Live Id凭据登录时,我收到的安全性错误如"An unsecured or incorrectly secured fault was received from the other party. See the inner FaultException for the fault code and detail."
请告诉我如何使用实时ID详细信息登录。
注意:我使用SDK authenticationwithnohelp代码登录
答案 0 :(得分:0)
解决此类问题的最佳方法是查看调用CRM Web服务失败时生成的内部故障详细信息。抛出的异常类型通常是:
System.ServiceModel.FaultException<Microsoft.Xrm.Sdk.OrganizationServiceFault>
将代码包装在try / catch块中并检查异常Detail和Detail.InnerFault对象:
try
{
// Connection code here
}
catch (System.ServiceModel.FaultException<Microsoft.Xrm.Sdk.OrganizationServiceFault> ex)
{
string exceptionMessage = ex.Message;
int errorCode = -1;
// Check for fault detailed information
if (ex.Detail != null)
{
// Check for the Detail InnerFault
if (ex.Detail.InnerFault != null)
{
// Get the inner fault message and code - this is where the useful information is
exceptionMessage += " - " + ex.Detail.InnerFault.Message;
errorCode = ex.Detail.InnerFault.ErrorCode;
}
else
{
// No InnerFault was defined, get the Detail message and code
if (exceptionMessage != ex.Detail.Message)
{
// The Detail.Message will usually be the same as the outer exception
exceptionMessage += " - " + ex.Detail.Message;
}
errorCode = ex.Detail.ErrorCode;
}
}
// Output exceptionDetails and errorCode here
Trace.WriteLine("Exception message: " + exceptionMessage);
Trace.WriteLine("Exception code: " + errorCode);
}
异常错误代码属性也很有用。错误代码以十进制格式返回,例如-2147167730
您可以在此处针对MSDN上的CRM网络服务返回的错误代码列表进行交叉引用:http://msdn.microsoft.com/en-us/library/gg328182.aspx
但是,首先需要将错误代码从十进制转换为MSDN上使用的十六进制格式。
使用示例错误代码-2147167730: