CU4 of Studio 2019 - creating the project object leads to exception: "The requested service is not available: Sdl.Desktop.Platform.Services.IUserSettingsService."

Hi guys,

I have an issue with this code:

NewProj = New FileBasedProject(NewProjInfo)

When I do this, I get "The requested service is not available: Sdl.Desktop.Platform.Services.IUserSettingsService."

I am using this line of code for 10 years to create an empty project object and it always worked. But since I installed CU4 of STudio 2019 SR1, this code does not work any longer. 

Can you shed a light please?

Thanks, 

Tom

Parents
  • Hi Tom,

              There is a configuration issue in CU 4 that will be handled in CU 5 that will be released in the following months. In the meantime you can bypass this error using reflection like this  :

    1.) Add the following nuget package to your project or download it and extract the dll's : https://www.nuget.org/packages/SimpleInjector/

    2.) Using reflection we need to inject the container to GlobalServices so it can properly register all the services. Be aware that I put in the default location for that dll however if you have the API copied into another location you will have to change the path. Below is a code sample how to do that in C# : 

           var container = new SimpleInjector.Container();

           Assembly a = Assembly.LoadFile(@"C:\Program Files (x86)\SDL\SDL Trados Studio\Studio15\Sdl.Desktop.Platform.dll");

           Type myType = a.GetType("Sdl.Desktop.Platform.Services.GlobalServices");

           MethodInfo myMethod = myType.GetMethod("RegisterStandardServices");

           myMethod.Invoke(null, new object[] { container });

    Best regards,
    Robert

  • Hi,

    I'm getting sometimes a similar error ("The requested service is not available: Sdl.Desktop.Platform.Services.IMessageService.") or the same one ("The requested service is not available: Sdl.Desktop.Platform.Services.IUserSettingsService.") when trying to create a Filebased project.

    But in my case I run Trados Studio 2021 SR2.

    I did try the workaround described above, but  myType.GetMethod("RegisterStandardServices") gives me back a null as they is no RegisterStandardServices method in that DLL.

    Any pointer on how to make this work would be appreciated.

    Thanks,
    -yves

  • Hi Yves, 

              The workaround that I gave will no longer work for Trados Studio 2021 SR 2 as it was fixed in later CU's. Would you be so kind sharing a code snippet of how you use the API when this issue occurs. 

    Best regards,

    Robert 

  • Hi Robert,

    Here is a small example that fails for me:

    public FileBasedProject CreateProject(string projectDir,
    string name,
    string trdSource,
    string trdTarget)
    {
    // Set up the project
    ProjectInfo info = new ProjectInfo
    {
    Name = name,
    LocalProjectFolder = projectDir
    };

    // Set the source language
    info.SourceLanguage = new Language(trdSource);
    // Set the targets
    info.TargetLanguages = new Language[1] { new Language(trdTarget) };

    // Create the project
    FileBasedProject newProject = new FileBasedProject(info);

    newProject.Save();
    return newProject;
    }

    I call it as this:

    t21Test.CreateProject(@"C:\Temp\", "Testproject", "en-US", "fr-FR" );

    I get this exception when calling new FileBasedProject(info);

    Sdl.Desktop.Platform.Services.ServiceNotAvailableException
    HResult=0x80131500
    Message=The requested service is not available: Sdl.Desktop.Platform.Services.IMessageService.
    Source=Sdl.ProjectAutomation.FileBased
    StackTrace:
    at Sdl.ProjectAutomation.FileBased.FileBasedProject.GetDefaultProjectTemplateReference()
    at Sdl.ProjectAutomation.FileBased.FileBasedProject..ctor(ProjectInfo projectInfo)

    I import the following:

    using Sdl.Core.Globalization;
    using Sdl.ProjectAutomation.Core;
    using Sdl.ProjectAutomation.FileBased;

    thanks,

    -ys

Reply
  • Hi Robert,

    Here is a small example that fails for me:

    public FileBasedProject CreateProject(string projectDir,
    string name,
    string trdSource,
    string trdTarget)
    {
    // Set up the project
    ProjectInfo info = new ProjectInfo
    {
    Name = name,
    LocalProjectFolder = projectDir
    };

    // Set the source language
    info.SourceLanguage = new Language(trdSource);
    // Set the targets
    info.TargetLanguages = new Language[1] { new Language(trdTarget) };

    // Create the project
    FileBasedProject newProject = new FileBasedProject(info);

    newProject.Save();
    return newProject;
    }

    I call it as this:

    t21Test.CreateProject(@"C:\Temp\", "Testproject", "en-US", "fr-FR" );

    I get this exception when calling new FileBasedProject(info);

    Sdl.Desktop.Platform.Services.ServiceNotAvailableException
    HResult=0x80131500
    Message=The requested service is not available: Sdl.Desktop.Platform.Services.IMessageService.
    Source=Sdl.ProjectAutomation.FileBased
    StackTrace:
    at Sdl.ProjectAutomation.FileBased.FileBasedProject.GetDefaultProjectTemplateReference()
    at Sdl.ProjectAutomation.FileBased.FileBasedProject..ctor(ProjectInfo projectInfo)

    I import the following:

    using Sdl.Core.Globalization;
    using Sdl.ProjectAutomation.Core;
    using Sdl.ProjectAutomation.FileBased;

    thanks,

    -ys

Children