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
Reply
  • 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
Children