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
...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
- Why do I get this exception now, with Trados Studio 2019?
(Thestudio
object comes from the Sdl.Community.Toolkit.Core.Studio2017 NuGet package, and there doesn't appear to be a 2019 version of the package.) - 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?) - 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]