private static ISetupConfiguration GetQuery()

in src/MSBuildLocator/VisualStudioLocationHelper.cs [88:107]


        private static ISetupConfiguration GetQuery()
        {
            try
            {
                // Try to CoCreate the class object.
                return new SetupConfiguration();
            }

            catch (COMException ex) when (ex.ErrorCode == REGDB_E_CLASSNOTREG)
            {
                // Try to get the class object using app-local call.
                ISetupConfiguration query;
                var result = GetSetupConfiguration(out query, IntPtr.Zero);

                if (result < 0)
                    throw new COMException($"Failed to get {nameof(query)}", result);

                return query;
            }
        }