System.IndexOutOfRangeException when using Eventhandlers on FileBasedProject.RunAutomaticTask

Dear Community, Dear SDL devs,

we recently implemented an application using the Studio 2019 and 2021 API to automatically execute a whole translation process, including pretranslation, analysis and so on. We used the RunAutomaticTask (singular) method as described in the gitlab community examples. Our code resembles the following @ [1]

Unfortunately we get a „System.IndexOutOfRangeException: Der Index war außerhalb des Arraybereichs“, which occurs only when using the taskStatusEventArgsList and messageEventArgsList Eventhandlers like they are used in the SDL Github API examples.

If we run project.RunAutomaticTask with these two parameters, occasionally (round 10-50%) of the tasks pretranslate, analysis, populatetranslationmemories fail due to this exception. If we use the overload of project.RunAutomaticTask without Eventhandlers, the same project runs fine, but we would have no error handling, which would not be feasible for our customers.

Is there advice on using the RunAutomaticTask method without generating this kind of exception?




List<TaskStatusEventArgs> taskStatusEventArgsList = new List<TaskStatusEventArgs>();

List<MessageEventArgs> messageEventArgsList = new List<MessageEventArgs>();


AutomaticTask ptCreationTask = project.RunAutomaticTask(



(sender, TaskStatus) => { taskStatusEventArgsList.Add(TaskStatus); },

(sender, AnalyzeMessage) => { messageEventArgsList.Add(AnalyzeMessage); }


 // error occurs during RunAutomaticTask

CheckEvents (taskStatusEventArgsList, messageEventArgsList);

Top Replies