Trados Studio 2017 UpdateSegmentPair behaviour changed compared to 2015

 Hi,

I was using the following code in SDL Trados Studio 2015:

 

                var dseg = GetEditorController().ActiveDocument.ActiveSegmentPair;

                ISegmentPair tempSegmentPair = documentItemFactory.CreateSegmentPair(dseg.Source, dseg.Target);

                GetEditorController().ActiveDocument.UpdateSegmentPair(tempSegmentPair);

 

(Well in reality there were some processing steps which created a new target segment with documentItemFactory.)

Nevertheless the problem is that while it worked in 2015 the UpdateSegmentPair command now fails with a null reference exception apparently on this:

   <Source>Sdl.TranslationStudioAutomation.IntegrationApi</Source>
    <HResult>-2147467261</HResult>
    <StackTrace><![CDATA[   at Sdl.TranslationStudioAutomation.IntegrationApi.Document.GetSourceSegmentContainerNode(ISegmentPair segmentPair)
   at Sdl.TranslationStudioAutomation.IntegrationApi.Document.UpdateSegmentPair(ISegmentPair segmentPair)

What am I doing wrong?

Best: Peter