"Multiple ambiguous overloads" error when registering BatchExported event handler for TMX export

As mentioned recently elsewhere, I'm getting weird errors in my STraSAK when registering TMX export (and also import) event handler.
The same code runs just fine without errors with Studio 2014 and 2015, and I'm pretty sure it worked fine in earlier Studio 2017 versions (pre-SR1, like Studio 2017 CU5).

The code is PowerShell, but I'm pretty sure you get the idea since PS code looks very similar to C#...

This is the event handler (as PowerShell scriptblock). No rocket science, it just writes the number of processed and exported TUs to console:

# Event handler scriptblock
$OnBatchExported = {
    param([System.Object]$sender, [Sdl.LanguagePlatform.TranslationMemoryApi.BatchExportedEventArgs]$e)
    $TotalProcessed = $e.TotalProcessed
    $TotalExported = $e.TotalExported
    Write-Host "TUs processed: $TotalProcessed, exported: $TotalExported`r" -NoNewLine
}

And this is the relevant piece of the code - it's actually trivial, it gets a standard Studio TM object, creates TM exporter object, registers the event handler, runes the actual export and then unregisters the event handler. Again, no rocket science...

$TM = Get-FilebasedTM $SDLTM.FullName
$Exporter = New-Object Sdl.LanguagePlatform.TranslationMemoryApi.TranslationMemoryExporter ($TM.LanguageDirection)
$Exporter.Add_BatchExported($OnBatchExported)
$Exporter.Export("$TMXPath\$TMXName", ($Force.IsPresent))
$Exporter.Remove_BatchExported($OnBatchExported)

This code runs perfectly with Studio 2015, but fails with Studio 2017 (and also 2019) - see the video below.

The error 'Multiple ambiguous overloads found for "Add_BatchExported" and the argument count: "1"' would suggest that there is some difference in the API in Studio 2017/2019... yet, there is nothing mentioned in the relevant API documentation: producthelp.sdl.com/.../d829a063-705f-e34b-f504-a882125aed13.htm

BTW, the way the event handler is registered/unregistered is correct, see wensveen.wordpress.com/.../

EDIT:
Even the PrimalSense context help (which reads parameters directly from the DLLs) is not helpful since the event handler overloads are simply identical... That's really sick :(
How is one supposed to differentiate between these two?!?!

Screenshot showing an autocomplete suggestion for 'add_BatchExported' method with one parameter in Trados Studio.
Screenshot displaying a second autocomplete suggestion for 'add_BatchExported' method, indicating ambiguity in Trados Studio.

Play this video



Generated Image Alt-Text
[edited by: Trados AI at 1:18 PM (GMT 0) on 5 Mar 2024]
Parents
  • I guess this might need some insight from SDL people like  or ...

    Meanwhile I did some more research and it looks like there is indeed something weird in the API - comparing to previous versions, there is a new Sdl.Core.TM.ImportExport DLL in Studio 2017 (and 2019) and this DLL contains duplicates of the export/import routines... which causes the ambiguities.

    This DLL exists only since Studio 2017 CU13 released in October 2018, which perfectly confirms my previous suspicion that my code worked fine in earlier Studio 2017 versions!

    PS C:\Users\EvzenP> $Exporter.GetType().getmethods() | ? name -eq add_BatchExported | % {write-host "***`n" ; $_}
    ***

    Name                       : add_BatchExported
    DeclaringType              : Sdl.LanguagePlatform.TranslationMemoryApi.TranslationMemoryExporter
    ReflectedType              : Sdl.LanguagePlatform.TranslationMemoryApi.TranslationMemoryExporter
    MemberType                 : Method
    MetadataToken              : 100664463
    Module                     : Sdl.LanguagePlatform.TranslationMemoryApi.dll
    IsSecurityCritical         : True
    IsSecuritySafeCritical     : False
    IsSecurityTransparent      : False
    MethodHandle               : System.RuntimeMethodHandle
    Attributes                 : PrivateScope, Public, HideBySig, SpecialName
    CallingConvention          : Standard, HasThis
    ReturnType                 : System.Void
    ReturnTypeCustomAttributes : Void
    ReturnParameter            : Void
    IsGenericMethod            : False
    IsGenericMethodDefinition  : False
    ContainsGenericParameters  : False
    MethodImplementationFlags  : Managed
    IsPublic                   : True
    IsPrivate                  : False
    IsFamily                   : False
    IsAssembly                 : False
    IsFamilyAndAssembly        : False
    IsFamilyOrAssembly         : False
    IsStatic                   : False
    IsFinal                    : False
    IsVirtual                  : False
    IsHideBySig                : True
    IsAbstract                 : False
    IsSpecialName              : True
    IsConstructor              : False
    CustomAttributes           : {[System.Runtime.CompilerServices.CompilerGeneratedAttribute()]}

    ***

    Name                       : add_BatchExported
    DeclaringType              : Sdl.Core.TM.ImportExport.Exporter
    ReflectedType              : Sdl.LanguagePlatform.TranslationMemoryApi.TranslationMemoryExporter
    MemberType                 : Method
    MetadataToken              : 100663311
    Module                     : Sdl.Core.TM.ImportExport.dll
    IsSecurityCritical         : True
    IsSecuritySafeCritical     : False
    IsSecurityTransparent      : False
    MethodHandle               : System.RuntimeMethodHandle
    Attributes                 : PrivateScope, Public, HideBySig, SpecialName
    CallingConvention          : Standard, HasThis
    ReturnType                 : System.Void
    ReturnTypeCustomAttributes : Void
    ReturnParameter            : Void
    IsGenericMethod            : False
    IsGenericMethodDefinition  : False
    ContainsGenericParameters  : False
    MethodImplementationFlags  : Managed
    IsPublic                   : True
    IsPrivate                  : False
    IsFamily                   : False
    IsAssembly                 : False
    IsFamilyAndAssembly        : False
    IsFamilyOrAssembly         : False
    IsStatic                   : False
    IsFinal                    : False
    IsVirtual                  : False
    IsHideBySig                : True
    IsAbstract                 : False
    IsSpecialName              : True
    IsConstructor              : False
    CustomAttributes           : {[System.Runtime.CompilerServices.CompilerGeneratedAttribute()]}

    So I would like to get some feedback from SDL... most probably a confirmation of the issue and also a suggestion for a temporary workaround, plus ideally some word about planned fix.

Reply
  • I guess this might need some insight from SDL people like  or ...

    Meanwhile I did some more research and it looks like there is indeed something weird in the API - comparing to previous versions, there is a new Sdl.Core.TM.ImportExport DLL in Studio 2017 (and 2019) and this DLL contains duplicates of the export/import routines... which causes the ambiguities.

    This DLL exists only since Studio 2017 CU13 released in October 2018, which perfectly confirms my previous suspicion that my code worked fine in earlier Studio 2017 versions!

    PS C:\Users\EvzenP> $Exporter.GetType().getmethods() | ? name -eq add_BatchExported | % {write-host "***`n" ; $_}
    ***

    Name                       : add_BatchExported
    DeclaringType              : Sdl.LanguagePlatform.TranslationMemoryApi.TranslationMemoryExporter
    ReflectedType              : Sdl.LanguagePlatform.TranslationMemoryApi.TranslationMemoryExporter
    MemberType                 : Method
    MetadataToken              : 100664463
    Module                     : Sdl.LanguagePlatform.TranslationMemoryApi.dll
    IsSecurityCritical         : True
    IsSecuritySafeCritical     : False
    IsSecurityTransparent      : False
    MethodHandle               : System.RuntimeMethodHandle
    Attributes                 : PrivateScope, Public, HideBySig, SpecialName
    CallingConvention          : Standard, HasThis
    ReturnType                 : System.Void
    ReturnTypeCustomAttributes : Void
    ReturnParameter            : Void
    IsGenericMethod            : False
    IsGenericMethodDefinition  : False
    ContainsGenericParameters  : False
    MethodImplementationFlags  : Managed
    IsPublic                   : True
    IsPrivate                  : False
    IsFamily                   : False
    IsAssembly                 : False
    IsFamilyAndAssembly        : False
    IsFamilyOrAssembly         : False
    IsStatic                   : False
    IsFinal                    : False
    IsVirtual                  : False
    IsHideBySig                : True
    IsAbstract                 : False
    IsSpecialName              : True
    IsConstructor              : False
    CustomAttributes           : {[System.Runtime.CompilerServices.CompilerGeneratedAttribute()]}

    ***

    Name                       : add_BatchExported
    DeclaringType              : Sdl.Core.TM.ImportExport.Exporter
    ReflectedType              : Sdl.LanguagePlatform.TranslationMemoryApi.TranslationMemoryExporter
    MemberType                 : Method
    MetadataToken              : 100663311
    Module                     : Sdl.Core.TM.ImportExport.dll
    IsSecurityCritical         : True
    IsSecuritySafeCritical     : False
    IsSecurityTransparent      : False
    MethodHandle               : System.RuntimeMethodHandle
    Attributes                 : PrivateScope, Public, HideBySig, SpecialName
    CallingConvention          : Standard, HasThis
    ReturnType                 : System.Void
    ReturnTypeCustomAttributes : Void
    ReturnParameter            : Void
    IsGenericMethod            : False
    IsGenericMethodDefinition  : False
    ContainsGenericParameters  : False
    MethodImplementationFlags  : Managed
    IsPublic                   : True
    IsPrivate                  : False
    IsFamily                   : False
    IsAssembly                 : False
    IsFamilyAndAssembly        : False
    IsFamilyOrAssembly         : False
    IsStatic                   : False
    IsFinal                    : False
    IsVirtual                  : False
    IsHideBySig                : True
    IsAbstract                 : False
    IsSpecialName              : True
    IsConstructor              : False
    CustomAttributes           : {[System.Runtime.CompilerServices.CompilerGeneratedAttribute()]}

    So I would like to get some feedback from SDL... most probably a confirmation of the issue and also a suggestion for a temporary workaround, plus ideally some word about planned fix.

Children