Opening project via API causes error in Trados Studio 2024 CU1

Greetings!

I’m developing standalone app using Studio API to automate some translation tasks in our company. I recently updated Trados Studio 2024 to CU1. Since then I have received following error when trying to open project by creating an instance of FileBasedProject with project path as argument:

Screenshot of code snippet with a method named GetMemoryPath. It shows instantiation of FileBasedProject and retrieval of a URI from project configuration.

Unhandled Exception: System.Exception: The registered delegate for type IUrlsConfig threw an exception. Application is not configured for BestMatchServiceUrlsConfig. ---> SimpleInjector.ActivationException: The registered delegate for type IUrlsConfig threw an exception. Application is not configured for BestMatchServiceUrlsConfig. ---> System.ApplicationException: Application is not configured for BestMatchServiceUrlsConfig.
at Sdl.BestMatchServiceStudioIntegration.Common.UrlsConfig.get_Config()
at Sdl.BestMatchServiceStudioIntegration.Common.BestMatchServiceStudioIntegrationCommonModule.<>c.<RegisterCommonClasses>b__2_0()
at lambda_method(Closure )
at SimpleInjector.Lifestyles.SingletonLifestyle.SingletonRegistration.Execute(Func`1 instanceCreator)
at
SimpleInjector.Lifestyles.SingletonLifestyle.SingletonRegistration.GetInterceptedInstanceWithNullCheck()
at SimpleInjector.Lifestyles.SingletonLifestyle.SingletonRegistration.GetInterceptedInstance()
at SimpleInjector.Lifestyles.SingletonLifestyle.SingletonRegistration.BuildExpression()
at SimpleInjector.InstanceProducer.BuildExpressionInternal()
at SimpleInjector.Internals.LazyEx`1.InitializeAndReturn()
at SimpleInjector.InstanceProducer.BuildExpression()
at SimpleInjector.Registration.BuildConstructorParameters(ConstructorInfo constructor)
at SimpleInjector.Registration.BuildNewExpression()
at SimpleInjector.Registration.BuildTransientExpression()
at

<Same block repeats several times>…

SimpleInjector.Lifestyles.SingletonLifestyle.SingletonRegistration.GetInterceptedInstanceWithNullCheck()
at SimpleInjector.Lifestyles.SingletonLifestyle.SingletonRegistration.GetInterceptedInstance()
at SimpleInjector.Lifestyles.SingletonLifestyle.SingletonRegistration.BuildExpression()
at SimpleInjector.InstanceProducer.BuildExpressionInternal()
at SimpleInjector.Internals.LazyEx`1.InitializeAndReturn()
at SimpleInjector.InstanceProducer.BuildInstanceCreator()
at SimpleInjector.InstanceProducer.BuildAndReplaceInstanceCreatorAndCreateFirstInstance()
at SimpleInjector.InstanceProducer.GetInstance()
at SimpleInjector.Container.GetInstanceForRootType(Type serviceType)
at SimpleInjector.Container.GetInstance[TService]()
at Sdl.ProjectAutomation.FileBased.ProjectApiBootstrapper.RegisterMinimumAPIFunctionalityTypes()
at Sdl.ProjectAutomation.FileBased.FileBasedProject.EnsurePluginRegistryIsCreated()
at Sdl.ProjectAutomation.FileBased.FileBasedProject..ctor(String projectFilePath)
--- End of inner exception stack trace ---
at Sdl.ProjectAutomation.FileBased.FileBasedProject..ctor(String projectFilePath)

The error would seem to indicate I lack BestMatchServiceUrlsConfig from my app.config file. I tried to add it to my configuration using same settings as in Trados Studio but I still receive the same error. The code works fine in previous version (18.0.0.1013). I wonder what has changed to cause the issue?

Thank you in Advance

Miikka



Generated Image Alt-Text
[edited by: RWS Community AI at 6:06 AM (GMT 0) on 15 Nov 2024]
Parents
  • Hi Miikka, 

             Seems there is something missing from the registration of the API on our side. Thank you for notifying us we created a ticket to fix it : LG-46480. Unfortunately there is no workaround to fix this and make the app work so I would suggest to use the previous version 18.0.0.1013. This issue is planned to be fixed in the next release. 

    Best regards,

    Cornea Robert

  • Hi Robert,

    I tried the beta 1 of CU 2 and the issue seems to persist. I changed the references of the project to point to beta folder, but got the following error:

    System.Exception: 'The registered delegate for type IUrlsConfig threw an exception. Application is not configured for BestMatchServiceUrlsConfig.'

    This exception was originally thrown at this call stack:
    Sdl.BestMatchServiceStudioIntegration.Common.BestMatchServiceStudioIntegrationCommonModule.GetUrlsConfig(Sdl.Platform.Interfaces.DI.IContainer)
    Sdl.BestMatchServiceStudioIntegration.Common.BestMatchServiceStudioIntegrationCommonModule.RegisterCommonClasses.AnonymousMethod__0()
    SimpleInjector.Lifestyles.SingletonLifestyle.SingletonRegistration.Execute(System.Func<object>)
    SimpleInjector.Lifestyles.SingletonLifestyle.SingletonRegistration.GetInterceptedInstanceWithNullCheck()
    SimpleInjector.Lifestyles.SingletonLifestyle.SingletonRegistration.GetInterceptedInstance()
    SimpleInjector.Lifestyles.SingletonLifestyle.SingletonRegistration.BuildExpression()
    SimpleInjector.InstanceProducer.BuildExpressionInternal()
    SimpleInjector.Internals.LazyEx<T>.InitializeAndReturn()
    SimpleInjector.InstanceProducer.BuildExpression()

    I wonder if I'm missing something?

    Kind regards,
    Miikka Wirtanen

  • Hi  ,

           We tested with the following sample app : 

    Screenshot of a code editor with C# code for the SDL SDK ProjectAutomation. The code initializes a FileBasedProject and prints a URI. A command prompt window is shown at the bottom displaying a file path and 'Press Enter to continue...'.

               And by running the app in the Studio folder, in your case in the StudioBeta18 folder. 

               Another thing that can happen is that you app startup path is missing this file : SDLTradosStudio.exe.config.

               Try running this code : 

    internal string GetConfigurationFile()
    {
    var configFilename = Path.Combine(Application.StartupPath, "SDLTradosStudio.exe.config");
    if (File.Exists(configFilename))
    {
    return configFilename;
    }

    configFilename = Path.Combine(Application.StartupPath, "Sdl.BestMatchServiceStudioIntegration.Common.dll.config");
    if (File.Exists(configFilename))
    {
    return configFilename;
    }

    return Path.Combine(Directory.GetCurrentDirectory(), "SDLTradosStudio.exe.config");
    }

             And see if the path returned contains that configuration file. 

    Best regards,

    Cornea Robert



    Generated Image Alt-Text
    [edited by: RWS Community AI at 11:59 AM (GMT 0) on 3 Dec 2024]
  • Hi Robert,

    The code runs fine in the Studio folder for me as well. The problems start if I try to run it in some separate folder. I figured I'm missing at least the Sdl.BestMatchServiceStudioIntegration.Common.dll.config from my folder and indeed putting it there resolves the aforementioned problem. But it seems it's still missing something:

    System.Exception: 'The registered delegate for type IUrlsConfig threw an exception. Unrecognized attribute 'login'. Note that attribute names are case-sensitive.

    This exception was originally thrown at this call stack:
    System.Configuration.BaseConfigurationRecord.EvaluateOne(string[], System.Configuration.SectionInput, bool, System.Configuration.FactoryRecord, System.Configuration.SectionRecord, object)
    System.Configuration.BaseConfigurationRecord.Evaluate(System.Configuration.FactoryRecord, System.Configuration.SectionRecord, object, bool, bool, out object, out object)
    System.Configuration.BaseConfigurationRecord.GetSectionRecursive(string, bool, bool, bool, bool, out object, out object)
    Sdl.BestMatchServiceStudioIntegration.Common.Configuration.CloudConfigurationProvider.GetConfigSection<T>(string)
    Sdl.BestMatchServiceStudioIntegration.Common.BestMatchServiceStudioIntegrationCommonModule.GetUrlsConfig(Sdl.Platform.Interfaces.DI.IContainer)
    Sdl.BestMatchServiceStudioIntegration.Common.BestMatchServiceStudioIntegrationCommonModule.RegisterCommonClasses.AnonymousMethod__0()
    SimpleInjector.Lifestyles.SingletonLifestyle.SingletonRegistration.Execute(System.Func<object>)
    SimpleInjector.Lifestyles.SingletonLifestyle.SingletonRegistration.GetInterceptedInstanceWithNullCheck()
    SimpleInjector.Lifestyles.SingletonLifestyle.SingletonRegistration.GetInterceptedInstance()
    SimpleInjector.Lifestyles.SingletonLifestyle.SingletonRegistration.BuildExpression()

    Curiously, the absence of that config file doesn't seem to cause such issues with Studio 2022. I can of course run my automation from Studio folder, but it would be convenient if I could use it from elsewhere.

    Kind regards,

    Miikka Wirtanen

  • Hi  ,

              Studio 2022 and Studio 2024 ca considered 2 different app. In 2024 we did a lot of work on the infrastructure also added new functionality. Try to copy SDLTradosStudio.exe.config from the Studio 2024 folder see if that will fix it. 

               The API's were developed with focus on the Studio plugins rather than running with a different app. That is the reason why we recommend running automation from the Studio folder. Things like configuration files, paths can change from release to release and make 3rd party apps unstable. 

    Best regards,

    Cornea Robert

                 

Reply Children
No Data