{"id":69,"date":"2012-02-28T11:03:00","date_gmt":"2012-02-28T05:33:00","guid":{"rendered":"https:\/\/www.inogic.com\/blog\/?p=69"},"modified":"2012-02-28T11:03:00","modified_gmt":"2012-02-28T05:33:00","slug":"issue-with-plug-in-in-crm-2011","status":"publish","type":"post","link":"https:\/\/www.inogic.com\/blog\/2012\/02\/issue-with-plug-in-in-crm-2011\/","title":{"rendered":"Issue with plug-in in CRM 2011"},"content":{"rendered":"<div dir=\"ltr\" trbidi=\"on\">\n<div align=\"justify\">We had a requirement to do some calculation and update self record of custom entity. We have created a plug-in and registered it on post operation of update event. The code was reading the post image, updating some fields and updating the same.<\/p>\n<p>The plug-in was working fine for single record. But when two records are saved simultaneously, the plug-in was giving below errors randomly.<\/p><\/div>\n<p><\/p>\n<div align=\"justify\">1. &#8220;ValidateOpen &#8211; Encountered disposed CrmDbConnection when it should not be disposed&#8221;<br \/>2. &#8220;You cannot create a SqlExecutionContext from another SqlExecutionContext on which OnBeginRequest has not been called&#8221;<br \/>3. &#8221; System.InvalidOperationException: Microsoft Dynamics CRM has experienced an error. Reference number for administrators or support: #58919D7E&#8221;<br \/>4. &#8220;System.NullReferenceException: Microsoft Dynamics CRM has experienced an error. Reference number for administrators or support: #1638FFA8&#8221;<\/p>\n<p>When we checked in the Event viewer then we got that whatever error we get from CRM the Event viewer shows &#8220;System.InvalidOperationException: There is already an open DataReader associated with this Command which must be closed first.&#8221; error.<\/p>\n<p>After searching on net we found that CRM does not re-initialize the plug-in object again, it uses the same object. In the plug-in, ignore to use class level variables. We had created service object at class level so it was using the same service object for retrieving and updating.<\/p>\n<p>Also we were reading post image and updating the post image as it is. This was also creating a problem. Please create a new object of Entity and then set only those fields which you want to update. Then update the record.<\/p>\n<p>Sometimes this plug-in takes too much time as it was doing so many calculation. We were getting the &#8220;Query execution time of 30.1 seconds exceeded the threshold of 10 seconds. Thread: 4; Database: inogic_MSCRM &#8221; error when plug-in takes time. To resolve this, please add below keys in the registry on CRM server.<br \/>1) HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\MSCRM\\OLEDBTimeout<br \/><strong>a<\/strong>. In seconds<br \/><strong>b.<\/strong> The OLEDBTimeout value controls the SQL time-out value that is used for a single SQL query<br \/><strong>c.<\/strong> Set it to 60 seconds <\/div>\n<p><\/p>\n<div align=\"justify\">2) HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\MSCRM\\ExtendedTimeout<br \/><strong>a.<\/strong> In milliseconds<br \/><strong>b.<\/strong> The ExtendedTimeout value controls the ASP.NET time-out value<br \/><strong>c.<\/strong> Set it to 1,000,000 <\/div>\n<p><\/p>\n<div align=\"justify\">3) HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\MSCRM\\NormalTimeout<br \/><strong>a.<\/strong> In milliseconds<br \/><strong>b.<\/strong> Specifies the SOAP call timeout for most operations<br \/><strong>c.<\/strong> Set it to 300,000<\/div>\n<p><\/p>\n<div align=\"justify\">Hope this helps!!<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>We had a requirement to do some calculation and update self record of custom entity. We have created a plug-in and registered it on post operation of update event. The code was reading the post image, updating some fields and updating the same. The plug-in was working fine for single record. But when two records\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.inogic.com\/blog\/2012\/02\/issue-with-plug-in-in-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,21,22,24,42],"tags":[745,1240,1330],"class_list":["post-69","post","type-post","status-publish","format-standard","hentry","category-dynamics-crm-2011","category-dynamics-crm-2013","category-dynamics-crm-2015","category-dynamics-crm-2016","category-plugin","tag-error","tag-multiple-users","tag-plugins"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts\/69","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=69"}],"version-history":[{"count":0,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts\/69\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/media?parent=69"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/categories?post=69"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/tags?post=69"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}