Unexpected exception when initializing task 'Populate Project Translation Memories'.

"An error occured creating a file based translation memory.."

I'he got an error during creating project using API. There is no details, there is no additional information, just the information above. And the task history:

Screenshot of Studio Developers Q&A task results window showing an error. The task 'Apply PerfectMatch Pre-translate Files-Populate Project Translation Memories' failed with the message 'An error occurred creating a file based translation memory.'



Generated Image Alt-Text
[edited by: RWS Community AI at 5:53 AM (GMT 0) on 15 Nov 2024]
Parents Reply Children
  • Would you be able to send me the project you are having problems with and also the code? My email address is rocrisan@sdl.com

    Romulus Crisan | Translation Productivity Development Manager | SDL | (twitter) @cromica_82 | (blog) http://www.romuluscrisan.com/

  • I'm having constant problems with this in a slightly different situation, but probably caused by the same problem...

    I get unpredictable crashes when creating project packages using "Create new project translation memory" package option - both in 'standard' use of Trados Studio and via API (using PowerShell toolkit).
    This does NEVER happen if the "Create new project TM" option is not used... therefore I strongly believe that it has something to do with this thread.

    I have different projects containing different source file types and 10+ target languages (sometimes 13, sometims 36, etc.). And creating translation packages keeps crashing at different stages/languages due to OutOfMemory exception, which causes the temporary/working package not being created in the TMP directory, so the subsequent subprocess, which wants to copy this temp package to the project and to the target location, fails...

    This is my typical situation when I start the packages creation (and pray that it actually completes):

    Now I click back, don't change anything and start the packages creation again... and most probably it WILL crash again (at unpredictable point)... :-\

    -------

    I'm now seeing the same behavior when generating packages via API (using PowerShell Tookit).
    Monitoring the memory usage shows constant growth with every new language up to a certain point, where the creation sort of stalls... and then crashes:

    Here is the piece of code responsible for the packages creation. I don't see anything obviously wrong here... actually I even tried to add the Remove-Variable line in an attempt to forcibly free some resources, but it didn't help much (it's visible as little drops in memory usage in the above graph, but obviously it's not the main memory-eater).

        "`nCreating packages..."
        # Loop through target languages and create package for each one
        Get-Languages $TargetLanguagesList | ForEach {
            
            $Language = $_
            $User = "$($Language.IsoAbbreviation) translator"
            # Set package name to project name with target language ISO code suffix
            $PackageName = $Project.GetProjectInfo().Name + "_" + $($Language.IsoAbbreviation)
            
            "$PackageName"
            
            # Get TaskFileInfo (files list) data for the target language's project files
            [Sdl.ProjectAutomation.Core.TaskFileInfo[]] $TaskFiles = Get-TaskFileInfoFiles $Project $Language
            # Create the manual task which will be associated with files being included in the package
            [Sdl.ProjectAutomation.Core.ManualTask] $ManualTask = $Project.CreateManualTask($Task, $User, $PackageDueDate, $TaskFiles)
            
            # Create package containing the manual task
            [Sdl.ProjectAutomation.Core.ProjectPackageCreation] $Package = $Project.CreateProjectPackage($ManualTask.Id, $PackageName, $PackageComment, $PackageOptions)
            
            # Save the package to file in specified location
            $PackagePath = $PackageLocation + "\" + $PackageName + ".sdlppx"
            $Project.SavePackageAs($Package.PackageId, $PackagePath)
            
            Remove-Variable TaskFiles, ManualTask, Package
        }
  • Would you be able to share with me some of this projects to do some testing?

    Romulus Crisan | Translation Productivity Development Manager | SDL | (twitter) @cromica_82 | (blog) http://www.romuluscrisan.com/

  • I suppose I would have to provide you also the TMs, so that you can have exactly the same conditions/environment... which I'm not sure I'm entitled to do :-\. Let me see...

    Meanwhile I have added simple event handlers to get more detailed info about what is happening (with intentionally crazy colors for debugging purposes ;-) ):

    function Progress {
        param(
        [Sdl.ProjectAutomation.FileBased.FileBasedProject] $Project,
        [Sdl.ProjectAutomation.Core.PackageStatusEventArgs] $ProgressEventArgs
        )
        
        if ($ProgressEventArgs.StatusMessage -ne $null -and $ProgressEventArgs.StatusMessage -ne "") {
            Write-Host "  $($ProgressEventArgs.PercentComplete)%    $($ProgressEventArgs.StatusMessage)"
        }
    }

    function Message {
        param(
            $Project,
            $MessageEventArgs
        )
        
        Write-Host "$($MessageEventArgs.Message.Source)" -ForegroundColor blue
        Write-Host "$($MessageEventArgs.Message.Level): $($MessageEventArgs.Message.Exception)" -ForegroundColor magenta
    }

    This is the package creation part:

    .
    .
            # Create package containing the manual task
            [Sdl.ProjectAutomation.Core.ProjectPackageCreation] $Package = $Project.CreateProjectPackage($ManualTask.Id, $PackageName, $PackageComment, $PackageOptions, ($function:Progress), ($function:Message))
            
            # Save the package to file in specified location
            $PackagePath = $PackageLocation + "\" + $PackageName + ".sdlppx"
            if ($Package.PackageId -ne $null) {
                $Project.SavePackageAs($Package.PackageId, $PackagePath)
            }
            else {
            "Package creation failed, cannot save it!"
            }
    .
    .

    And this is the actual output - the red text are errors thrown by PowerShell itself.
    Again, the project automation exceptions are intermittent - these happen randomly at first package, fourth package, etc... But it's always about "failing to save project". (And no, it's not due to not enough free space in %TMP%).

    D:\15>CreatePackages.cmd
    log4net:ERROR XmlConfigurator: Failed to find configuration section 'log4net' in the application's .config file. Check your .config file for the <log4net> and <configSections> elements. The configuration section should look like: <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net" />

    Creating packages...
    161013_HO249_20161012_OneCode_Drop2016-10_cs-CZ
      0%    Initializing package
      20%   Adding files
      70%   Compressing package
      100%  Compressing package
    161013_HO249_20161012_OneCode_Drop2016-10_de-DE
      0%    Initializing package
      20%   Adding files
      70%   Compressing package
      100%  Compressing package
    161013_HO249_20161012_OneCode_Drop2016-10_es-ES
      0%    Initializing package
      20%   Adding files
      70%   Compressing package
      100%  Compressing package
    161013_HO249_20161012_OneCode_Drop2016-10_fr-FR
      0%    Initializing package
      20%   Adding files
      70%   Compressing package
      100%  Compressing package
    161013_HO249_20161012_OneCode_Drop2016-10_it-IT
      0%    Initializing package
      20%   Adding files
      70%   Compressing package
      100%  Compressing package
    161013_HO249_20161012_OneCode_Drop2016-10_ja-JP
      0%    Initializing package
      20%   Adding files
      70%   Compressing package
    Create Project Package
    Error: Sdl.ProjectAutomation.Core.ProjectAutomationException: Failed to save project '161013_HO249_20161012_OneCode_Drop2016-10' to 'C:\TMP\TmpPkg36\161013_HO249_20161012_OneCode_Drop2016-10_ja-JP-20161020-22h52m18s.sdlproj':
    Object reference not set to an instance of an object. ---> Sdl.ProjectApi.ProjectApiException: Failed to save project '161013_HO249_20161012_OneCode_Drop2016-10' to 'C:\TMP\TmpPkg36\161013_HO249_20161012_OneCode_Drop2016-10_ja-JP-20161020-22h52m18s.sdlproj':
    Object reference not set to an instance of an object. ---> System.NullReferenceException: Object reference not set to an instance of an object.
       at Sdl.ProjectApi.Implementation.SettingsBundlesList.SerializeSettingsBundle(Guid guid, ISettingsBundle settingsBundle)
       at Sdl.ProjectApi.Implementation.SettingsBundlesList.Save()
       at Sdl.ProjectApi.Implementation.Project.Save()                                                                                                                                                         23:14
       --- End of inner exception stack trace ---
       at Sdl.ProjectApi.Implementation.Project.Save()
       at Sdl.ProjectApi.Implementation.AbstractProjectPackageCreation.StartImpl()
       at Sdl.ProjectApi.Implementation.PackageOperation.Start()
       --- End of inner exception stack trace ---
    Exception calling "SavePackageAs" with "2" argument(s): "Could not find file 'D:\15\02_trados_localization\Packages\Out\161013_HO249_20161012_OneCode_Drop2016-10_ja-JP-20161020-22h52m18s.sdlppx'."At D:\Docum ents\WindowsPowerShell\Modules\PackageHelper\PackageHelper.psm1:142 char:4
    +             $Project.SavePackageAs($Package.PackageId, $PackagePath)
    +             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
        + FullyQualifiedErrorId : FileNotFoundException

    161013_HO249_20161012_OneCode_Drop2016-10_ko-KR
      0%    Initializing package
      20%   Adding files
      70%   Compressing package
    Create Project Package
    Error: Sdl.ProjectAutomation.Core.ProjectAutomationException: Failed to save project '161013_HO249_20161012_OneCode_Drop2016-10' to 'D:\15\02_trados_localization\161013_HO249_20161012_OneCode_Drop2016-10.sdlproj':
    Exception of type 'System.OutOfMemoryException' was thrown. ---> Sdl.ProjectApi.ProjectApiException: Failed to save project '161013_HO249_20161012_OneCode_Drop2016-10' to 'D:\15\02_trados_localization\161013_HO249_20161012_OneCode_Drop2016-10.sdlproj':
    Exception of type 'System.OutOfMemoryException' was thrown. ---> System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.
       at System.Xml.XmlDocument.CreateTextNode(String text)
       at System.Xml.XmlNodeWriter.WriteString(String text)
       at System.Xml.XmlWriter.WriteAttributeString(String localName, String value)
       at Sdl.Core.Settings.Implementation.Xml.Setting.WriteXml(XmlWriter writer)
       at Sdl.Core.Settings.Implementation.Xml.SettingsGroup.WriteXml(XmlWriter writer)
       at Sdl.Core.Settings.Implementation.Xml.SettingsBundle.WriteXml(XmlWriter writer)
       at Sdl.Core.Settings.Implementation.SettingsBundle.WriteXml(XmlWriter writer, Boolean includeInheritedSettings)
       at Sdl.ProjectApi.Implementation.Xml.SettingsBundle.SaveSettingsBundle(ISettingsBundle settingsBundle)
       at Sdl.ProjectApi.Implementation.SettingsBundlesList.SerializeSettingsBundle(Guid guid, ISettingsBundle settingsBundle)
       at Sdl.ProjectApi.Implementation.SettingsBundlesList.Save()
       at Sdl.ProjectApi.Implementation.Project.Save()
       --- End of inner exception stack trace ---
       at Sdl.ProjectApi.Implementation.Project.Save()
       at Sdl.ProjectApi.Implementation.AbstractProjectPackageCreation.StartImpl()
       at Sdl.ProjectApi.Implementation.PackageOperation.Start()
       --- End of inner exception stack trace ---
    161013_HO249_20161012_OneCode_Drop2016-10_pl-PL
    Exception calling "GetTargetLanguageFiles" with "1" argument(s): "Exception of type 'System.OutOfMemoryException' was thrown."At D:\Documents\WindowsPowerShell\Modules\ProjectHelper\ProjectHelper.psm1:332 ch ar:23
    +     ForEach($Taskfile in $Project.GetTargetLanguageFiles($Language)) {
    +                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
        + FullyQualifiedErrorId : OutOfMemoryException

    Multiple ambiguous overloads found for "CreateManualTask" and the argument count: "4".At D:\Documents\WindowsPowerShell\Modules\PackageHelper\PackageHelper.psm1:134 char:3
    +         [Sdl.ProjectAutomation.Core.ManualTask] $ManualTask = $Project.CreateManualTas ...
    +    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : NotSpecified: (:) [], MethodException
        + FullyQualifiedErrorId : MethodCountCouldNotFindBest

    Cannot find an overload for "CreateProjectPackage" and the argument count: "6".At D:\Documents\WindowsPowerShell\Modules\PackageHelper\PackageHelper.psm1:137 char:3
    +         [Sdl.ProjectAutomation.Core.ProjectPackageCreation] $Package = $Project.Create ...
    +    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : NotSpecified: (:) [], MethodException
        + FullyQualifiedErrorId : MethodCountCouldNotFindBest

    Package creation failed, cannot save it!
    Remove-Variable : Cannot find a variable with the name 'ManualTask'.At D:\Documents\WindowsPowerShell\Modules\PackageHelper\PackageHelper.psm1:148 char:3
    +         Remove-Variable TaskFiles, ManualTask, Package
    +         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : ObjectNotFound: (ManualTask:String) [Remove-Variable], ItemNotFoundException
        + FullyQualifiedErrorId : VariableNotFound,Microsoft.PowerShell.Commands.RemoveVariableCommand

    out-lineoutput : Exception of type 'System.OutOfMemoryException' was thrown.
        + CategoryInfo          : NotSpecified: (:) [out-lineoutput], OutOfMemoryException
        + FullyQualifiedErrorId : System.OutOfMemoryException,Microsoft.PowerShell.Commands.OutLineOutputCommand