Quantcast
Channel: Microsoft Dynamics CRM Forum - Recent Threads
Viewing all articles
Browse latest Browse all 46379

Problem with workflow executing

$
0
0

Hi. I have 100 000 records that need to be inserted into CRM. After insert I run workflow for each inserted record.

this is my code:

   public static void CallWorkFLow(XrmServiceContext crm, int i, List<My_Data>Client)
        {
            var cc = new ClientCredentials();
            cc.Windows.ClientCredential.UserName = "admin";
            cc.Windows.ClientCredential.Password = "admin";
            cc.Windows.ClientCredential.Domain = "mydomain";
            var service = new OrganizationServiceProxy
            (ServiceConfigurationFactory.CreateConfiguration<IOrganizationService>
            (new Uri("myserver/.../Organization.svc")), cc);
           
                foreach (var row in Client)
                {
                            try
                            {
                                ExecuteWorkflowRequest request = new ExecuteWorkflowRequest();
                                request.WorkflowId = new Guid("563BDA80-ED5D-4A37-9AC9-3BCF22018D66");
                                request.EntityId = new Guid(row.new_ClientId.ToString());
                                ExecuteWorkflowResponse response = (ExecuteWorkflowResponse)service.Execute(request);
                            }
                            catch (Exception ex)
                            {
                                writer.WriteLine("Error: ex.ToString());
                            }

              }
        }



This code work fine until the loop go over the 30 000, after that I get the message:


System.ServiceModel.Security.MessageSecurityException:Message security verification faild.---> System.InsuffucentMemoryException:Faild to allocate a managed memory buffer of 1869 bytes.

What I need to do to fix this error?


Viewing all articles
Browse latest Browse all 46379

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>