studio.GetStudioVersion() throws NullReferenceException

When developing a plugin against Studio 2017 I was able to determine the current version of Studio by calling

   var studio = new Studio();
   var version = studio.GetStudioVersion();

However, when run against Studio 2019 this throws a NullReferenceException (with the standard "Object reference not set to an instance of an object." message) with this basic stack trace

   at Sdl.Community.Toolkit.Core.Services.StudioVersionService.GetStudioVersion()
   at Sdl.Community.Toolkit.Core.Studio.GetStudioVersion()

Curiously, there's also a method studio.GetInstalledStudioVersion(), which returns

Screenshot showing the output of studio.GetInstalledStudioVersion() method with a count of 1, indicating only SDL Studio 2017 is recognized as installed.

...even though I have both 2017 and 2019 installed.

Ultimately what I'm trying to achieve is the path to the user's default 'Projects' directory.

Can anyone explain

  1. Why do I get this exception now, with Trados Studio 2019?
    (The studio object comes from the Sdl.Community.Toolkit.Core.Studio2017 NuGet package, and there doesn't appear to be a 2019 version of the package.)
  2. Why does studio.GetInstalledStudioVersion() say that only 2017 is installed?
    (I realise this could be due to a shortcoming of the Sdl.Community.Toolkit.Core.Studio2017 NuGet package, but what's the point in having such a method if it can only recognise a single version?)
  3. Is there a better way of determining the user's default \Projects directory?


Generated Image Alt-Text
[edited by: Trados AI at 1:11 PM (GMT 0) on 5 Mar 2024]
  • Hello

    The Sdl.Community.Toolkit.Core package version for Studio 2019 and Studio 2017 can be installed from Visual Studio NuGet (see below attached image):

    Visual Studio NuGet Package Manager showing Sdl.Community.Toolkit.Core version 1.0 for Trados Studio 2019 with no visible errors.

    • For Studio 2019, it is used the Sdl.Community.Toolkit.Core (the latest version is 1.0).
    • For Studio 2017, it is used the Sdl.Community.Toolkit.Core.Studio2017 (the latest version is 0.7.1).

    Both methods studio.GetStudioVersion() and studio.GetInstalledStudioVersion() should work witouth any errors, if the correct version of the Sdl.Community.Toolkit.Core, based on the application compatibility with Studio is used.

     

    With kind regards,

    Florentina-Lucia Caputa



    Generated Image Alt-Text
    [edited by: Trados AI at 1:11 PM (GMT 0) on 5 Mar 2024]