Here we have listed some of the common exceptions that one should handle in the code:
– DiscoveryServiceFault: If you are accessing the discovery Web service, you need to catch DiscoveryServiceFault exception.(See below code)
catch (FaultException< Microsoft.Xrm.Sdk.DiscoveryServiceFault> ex)
{
Console.WriteLine(“The application terminated with an error.”);
}
– OrganizationServiceFault: If you are accessing the organization Web service, you need to catch OrganizationServiceFault exception.(See below code)
catch (FaultException
{
Console.WriteLine(“The application terminated with an error.”);
}
– TimeoutException: This will occurred when take long time to execute CRM request.(See below code)
catch (System.TimeoutException ex)
{
Console.WriteLine(“The application terminated with an error.”);
}
– SecurityAccessDeniedException: When connecting to Microsoft Dynamics CRM Online, SecurityAccessDeniedException exception can be thrown if you use a valid Windows Live ID and your Live account is not associated with any Microsoft Dynamics CRM Online organization.(See below code)
catch (FaultException
{
Console.WriteLine(“The application terminated with an error.”);
}
– MessageSecurityException: A MessageSecurityException can be thrown if your Windows Live ID is not valid or Windows Live failed to authenticate you.
catch (FaultException
{
Console.WriteLine(“The application terminated with an error.”);
}