web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Starting lots of workflows causes problems with sandbox process

(0) ShareShare
ReportReport
Posted on by 4

Hi, we are in a process of upgrading our CRM all the way from 2011 to Dynamics 365 online. As a preparation we are configuring our organization on current 2011 version to be supported in every aspect for online version. I edited all the workflows and plugins to be able to function in sandbox.

We have a routine of generating lots of renewal orders once a month and we do it in a workflow which has a custom workflow activity. Activity calls a wcf service which starts a job in a new thread and returns immediately, so wf activity is not waiting for the service method to finish. If we start this wf on 250 sales orders at the same time, we get an error, but not just on this wf, some other system jobs can also fail because of this:

Unhandled Exception: Microsoft.Crm.CrmException: System.ServiceModel.CommunicationObjectFaultedException: Microsoft Dynamics CRM has experienced an error. Reference number for administrators or support: #FB9C7DBD  at Microsoft.Crm.Sandbox.SandboxCodeUnit.Execute(IExecutionContext context)  at Microsoft.Crm.Workflow.Services.ProxyCustomActivity.Execute(CodeActivityContext executionContext)

We DO NOT get the same problem if we run the workflow activity outside sandbox. Running wf on 20 after 20 orders, I could not reproduce the error. I added tracing in wf activity and don't see my trace text, so I guess activity could not be started at all.

Any suggestion is appreciated

*This post is locked for comments

I have the same question (0)
  • David Jennaway Profile Picture
    14,065 on at

    You may have reached some limits on the WCF configuration. This is controlled by the .config settings in the respective process, so it's worth checking for any differences between these settings in the respective config files (for the sandbox process, the async process and web.config (for synchronous, non-sandboxed))

  • Žarko Radevic Profile Picture
    4 on at

    Do you know where do I find config files for sandbox service? The only config file I found is CrmAsyncService.exe.config is Server\bin folder and it contains only one assemblyBinding element.

    What kind of limitations are you talking about? You think that the problem is that I am calling an external WCF service?

  • Daniel Wikell Profile Picture
    2,360 on at

    I would bet that the problem lies in the fact that you spawn multiple custom threads. When a plugin or workflow is running in sandbox mode, it is handled by the sandwork host process that in turn spawns the neccessary amount of sandbox worker processes for the actual plugin/workflow execution. From time to time you will see that new worker processes are spawned even though there were already existing idle ones. I guess the sandbox host determines that a sandbox worker is no longer needed and then terminates it. If you are immediately returning from the workflow process it could be that the sandbox host then sees the workflow as completed and that the sandbox worker can be safely terminated. This could explain why you don't see a problem for small amount of records (your threads finish in time before the default termination timer reaches its limit) and why you do see a problem with large amounts (your custom threads are still running when the worker process is terminated).

    What happens if you try an approach where you do all the work in the current workflow thread instead of creating new ones?

  • Žarko Radevic Profile Picture
    4 on at

    Thank you for your answer, but please read once again, it is in the WCF service where I create a new thread, workflow activity doesn't know anything about it. WF activity just calls the wcf service in a synchronous way, not async method versions you can get when generating proxy in Visual Studio. Thanks for explaining how it works, I think the problem could be in wcf service becoming unresponsive, but it is strange that I can't see my tracing and error says nothing that could indicate a timeout exception.

  • Daniel Wikell Profile Picture
    2,360 on at

    Ah my bad, I missed the part about the external service being the one spawning the threads. Yeah then you can disregard my previous reply for sure.

    What else could cause problems like this then... Possibly some kind of memory leak? How are you setting up the WCF-call from the WF? Is the Connection disposed properly after each call?

    Not sure why you see such different results when running in sandbox mode and in none-isolated mode though. Sandbox does impose a lot of security limitations so I guess it could block the connection classes from reading some WCF setting that is important for connection stability?

    Another problem we've ran into in the past when calling WCF-services from CRM is the connection being randomly force-closed before it is properly established. We've mitigated that particular problem by simply retrying the connection attempt up to 3 times which seems to work fine.

  • Žarko Radevic Profile Picture
    4 on at

    This is the way we are calling the WCF web service:

    using (var client = new CrmExternal.MyClient(binding, endPointAddress))
    {
     var success = false;
        try
        {
            var request = new MyRequest
            {
                OpportunityId = opp.Id,
                AuthenticatedUserId = context.InitiatingUserId
            };
            client.MyMethod(request);

            if (client.State != CommunicationState.Faulted){
                client.Close();
                success = true;
            }
        }
        finally{
            if (!success)
                client.Abort();
                       
        }
    }

    It is a service that functions as a proxy, it sends forward requests to other services, but we are keeping it the only one service which is accessed from CRM code. Again, if the error was in calling the service, why don't I see my trace text which I create in the beginning of the wf activity?

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
Varsha deshpande Profile Picture

Varsha deshpande 5

#2
JS-09031509-0 Profile Picture

JS-09031509-0 3

#3
Ciprian  P Profile Picture

Ciprian P 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans