{"id":98,"date":"2011-08-02T03:40:00","date_gmt":"2011-08-01T22:10:00","guid":{"rendered":"https:\/\/www.inogic.com\/blog\/?p=98"},"modified":"2011-08-02T03:40:00","modified_gmt":"2011-08-01T22:10:00","slug":"fault-and-exception-handling-in-dynamics-crm-2011","status":"publish","type":"post","link":"https:\/\/www.inogic.com\/blog\/2011\/08\/fault-and-exception-handling-in-dynamics-crm-2011\/","title":{"rendered":"Fault and Exception Handling in Dynamics CRM 2011"},"content":{"rendered":"<div align=\"justify\">Microsoft Dynamics CRM Web service can throw a number of exceptions. When we use Microsoft Dynamics CRM Web service in application development we need to handle service related exceptions. All Web service method calls use a communication channel to the server based on the Windows Communication Foundation (WCF) technology. In WCF terms, exceptions returned from the channel are <em>called faults<\/em>.<br \/>Here we have listed some of the common exceptions that one should handle in the code:<br \/>&#8211; <strong>DiscoveryServiceFault:<\/strong> If you are accessing the discovery Web service, you need to catch DiscoveryServiceFault exception.(See below code)<br \/>catch (FaultException< Microsoft.Xrm.Sdk.DiscoveryServiceFault> ex)<br \/>{<br \/>Console.WriteLine(&#8220;The application terminated with an error.&#8221;);<br \/>}<br \/>&#8211; <strong>OrganizationServiceFault:<\/strong> If you are accessing the organization Web service, you need to catch OrganizationServiceFault exception.(See below code)<\/p>\n<p>catch (FaultException<microsoft.xrm.sdk.organizationservicefault> ex)<br \/>{<br \/>Console.WriteLine(&#8220;The application terminated with an error.&#8221;);<br \/>}<br \/>&#8211; <strong>TimeoutException:<\/strong> This will occurred when take long time to execute CRM request.(See below code)<br \/>catch (System.TimeoutException ex)<br \/>{<br \/>Console.WriteLine(&#8220;The application terminated with an error.&#8221;);<br \/>}<br \/>&#8211; <strong>SecurityAccessDeniedException:<\/strong> 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)<br \/>catch (FaultException<securityaccessdeniedexception> ex)<br \/>{<br \/>Console.WriteLine(&#8220;The application terminated with an error.&#8221;);<br \/>}<br \/>&#8211; <strong>MessageSecurityException:<\/strong> A MessageSecurityException can be thrown if your Windows Live ID is not valid or Windows Live failed to authenticate you.<br \/>catch (FaultException<messagesecurityexception> ex)<br \/>{<br \/>Console.WriteLine(&#8220;The application terminated with an error.&#8221;);<br \/>}<br \/><\/messagesecurityexception><\/securityaccessdeniedexception><\/microsoft.xrm.sdk.organizationservicefault><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Microsoft Dynamics CRM Web service can throw a number of exceptions. When we use Microsoft Dynamics CRM Web service in application development we need to handle service related exceptions. All Web service method calls use a communication channel to the server based on the Windows Communication Foundation (WCF) technology. In WCF terms, exceptions returned from\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.inogic.com\/blog\/2011\/08\/fault-and-exception-handling-in-dynamics-crm-2011\/\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":13,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[20],"tags":[753,786],"class_list":["post-98","post","type-post","status-publish","format-standard","hentry","category-dynamics-crm-2011","tag-exception","tag-fault"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts\/98","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/users\/13"}],"replies":[{"embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/comments?post=98"}],"version-history":[{"count":0,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts\/98\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/media?parent=98"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/categories?post=98"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/tags?post=98"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}