Multiple custom terminology provider throws "Sequence contains more than one matching element"

Hi Everyone,

Developing a custom terminology provider and we have noticed that if we add multiple provider, then on opening any file for editing, we get an "Sequence contains more than one matching element" (see full stack trace in attached XML).

The provider's name are different that's for sure. The project termbase settings look like this (see attached txt document). So the termbase name seems unique as well. Regarding the provider, we have a constructor, which expect an URI (the same URI, that ITerminologyProviderFactory.CreateTerminologyProvider receives from studio), from which the extract the name of the termbase/provider

I am not sure, what we do wrong here. Decompiling studio API, we only see that it is using the termbase's names and provider's name in that function, from where the error comes, so we don't see how it can throw and error if the names are unique. Can you help us figure out, whar we are missing? Thank you for your help in advance.

Best regards,

Balazs

<SDLErrorDetails time="2022. 12. 09. 9:07:00">
  <ErrorMessage>Sequence contains more than one matching element</ErrorMessage>
  <Exception>
    <Type>System.InvalidOperationException, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</Type>
    <HelpLink />
    <Source>System.Core</Source>
    <HResult>-2146233079</HResult>
    <StackTrace><![CDATA[   at System.Linq.Enumerable.SingleOrDefault[TSource](IEnumerable`1 source, Func`2 predicate)
   at Sdl.TranslationStudio.Editor.Terminology.EditorTermbaseProvider.SetTermbases(IList`1 termbases)
   at Sdl.TranslationStudio.Editor.Terminology.TermAccessProvider.RegisterDocument(ITranslatableDocument document)
   at Sdl.TranslationStudio.Editor.Terminology.TermAccessProvider.editorService_DocumentOpened(IDocument document)
   at Sdl.TranslationStudio.Api.Editor.DocumentEventHandler.Invoke(IDocument document)
   at Sdl.TranslationStudio.Editor.EditorService.OnDocumentOpened(IDocument document)
   at Sdl.TranslationStudio.Editor.EditorService.document_Loaded(IDocument document)
   at Sdl.TranslationStudio.Api.Editor.AbstractInternalDocument.OnLoaded()
   at Sdl.TranslationStudio.Editor.TranslationEditor.TranslatableDocument.OnLoaded()
   at Sdl.TranslationStudio.Api.Editor.AbstractInternalDocument.AfterLoad(IJob job)]]></StackTrace>
  </Exception>
  <Environment>
    <ProductName>Trados Studio</ProductName>
    <ProductVersion>Studio17</ProductVersion>
    <EntryAssemblyFileVersion>17.0.3.11695</EntryAssemblyFileVersion>
    <OperatingSystem>Microsoft Windows 10 Home</OperatingSystem>
    <ServicePack>NULL</ServicePack>
    <OperatingSystemLanguage>1033</OperatingSystemLanguage>
    <CodePage>1252</CodePage>
    <LoggedOnUser>USER</LoggedOnUser>
    <DotNetFrameWork>4.0.30319.42000</DotNetFrameWork>
    <ComputerName>USER</ComputerName>
    <ConnectedToNetwork>True</ConnectedToNetwork>
    <PhysicalMemory>16620788 MB</PhysicalMemory>
  </Environment>
</SDLErrorDetails>
        <SettingsGroup Id="TerminologyProviderSettings">
          <Setting Id="TermbasesOrder">
            <ArrayOfstring xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
              <string>Kalcium (Dokumentation/ZZ_Kalcium_640+)</string>
              <string>Kalcium (Dokumentation/ZZ_Kalcium_Dokumentation)</string>
              <string>Printer Termbase</string>
            </ArrayOfstring>
          </Setting>
          <Setting Id="Termbases">
            <ArrayOfTermbase xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/Sdl.ProjectApi.Implementation.Xml">
              <Termbase>
                <enabledField>true</enabledField>
                <filterField i:nil="true">
                </filterField>
                <nameField>Kalcium (Dokumentation/ZZ_Kalcium_640+)</nameField>
                <settingsXmlField>&lt;?xml version="1.0" encoding="utf-16"?&gt;&lt;TermbaseSettings xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt;  &lt;Path&gt;kalcium.terminology://testserver/kalcium652#####Dokumentation#####ZZ_Kalcium_640+\%\Kalcium (Dokumentation/ZZ_Kalcium_640+)&lt;/Path&gt;  &lt;IsOpen&gt;false&lt;/IsOpen&gt;  &lt;Filter&gt;0&lt;/Filter&gt;  &lt;FilterHighlight&gt;false&lt;/FilterHighlight&gt;  &lt;Layout&gt;0&lt;/Layout&gt;  &lt;Local&gt;false&lt;/Local&gt;  &lt;IsCustom&gt;true&lt;/IsCustom&gt;&lt;/TermbaseSettings&gt;</settingsXmlField>
              </Termbase>
              <Termbase>
                <enabledField>true</enabledField>
                <filterField i:nil="true">
                </filterField>
                <nameField>Kalcium (Dokumentation/ZZ_Kalcium_Dokumentation)</nameField>
                <settingsXmlField>&lt;?xml version="1.0" encoding="utf-16"?&gt;&lt;TermbaseSettings xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt;  &lt;Path&gt;kalcium.terminology://testserver/kalcium652#####Dokumentation#####ZZ_Kalcium_Dokumentation\%\Kalcium (Dokumentation/ZZ_Kalcium_Dokumentation)&lt;/Path&gt;  &lt;IsOpen&gt;false&lt;/IsOpen&gt;  &lt;Filter&gt;0&lt;/Filter&gt;  &lt;FilterHighlight&gt;false&lt;/FilterHighlight&gt;  &lt;Layout&gt;0&lt;/Layout&gt;  &lt;Local&gt;false&lt;/Local&gt;  &lt;IsCustom&gt;true&lt;/IsCustom&gt;&lt;/TermbaseSettings&gt;</settingsXmlField>
              </Termbase>
            </ArrayOfTermbase>
          </Setting>
        </SettingsGroup>

emoji
Parents
  • Hi  , there is nothing in the API that is stopping you from adding multiple custom terminology providers to the project. 

    However they need to be sufficienly different, so far as they should have a different assembly name, provider id, name and if you have actions, then they should have different groups and ids. I would also use a different ns + update the package manifest...  etc... 
    I don't know if your persisted storage is an API endpoint or a resource file on your network, but worth mentioning that it should support sharing if you are now accessing it from multiple providers...
    I would also recommend to uniquely identify the provider with the scheme; both are using 'kalcium.terminology://'
    You need to remember that the plugin framework will attempt to register your plugin + actions in to the Trados Studio context and is unforgiving when it see duplicate ids.

    If you can't locate where it is getting stuck, then I would recommend to create a new project from scratch and copy in the code from the duplicate project.

    emoji
  • There is a misunderstanding here. I want to add multiple instance of the same custom terminology provider. Also I don't want to stop adding multiple instance of the same custom terminology provider. The problem is that there is an error from Trados, if i add more terminology provider from the same type, even though the instance's URI and name are unique. 

    So I have a custom terminology provider. On adding this provider the user chooses a termbase from the remote service (lets assume that the termbase names are unique), based on which the following URI us generated : "very.sample://SOME-URL#####SOME-TERMBASE-NAME" . You can add multiple instance from this provider for different termbases. When the AbstractTerminologyProvider receives this URI, it extract the unique termbase name and it uses that witha prefix as the provider's name (like: "Very sample provider (termbase name)". You can see this from the copied project settings part (those are "real" test data from the actual implementation)

    Yet the error  "Sequence contains more than one matching element" comes (see at my initial question)

    emoji
  • I want to add multiple instance of the same custom terminology provider.

    Hi  , it doesn't seem to be supported for tb providers with the API.  You could however allow the user to select multiple databases from a single provider, by extending the settings; similar to the Multitrans terminology provider integration.

    emoji
  • I beleive we are speaking about the same: Adding a custom terminology provider with different termbase settings to the same project (so multiple instances of the same object with different settings).

    For reproduction updated the github repro (https://github.com/eurocombfeher/SampleProvider ). Use the plugin for Studio 2022

    1. Open a project, then add a "Very sample" provider, then make it default
    2. Add another "Very Sample" provider and make it default as well (I am not sure both should be the top 2 provider, but i am sureone should be set as default)
    3. Save the project
    4. Restart studio
    5. Open any file inside the project
    6. On opening the file, you will get that "Sequence contains more than one matching element" error
    emoji
Reply Children
No Data