/// <summary>Get a WinRT activation factory for a given type name.</summary>
        /// <param name="componentPath">The path to the WinRT component that the type is expected to be defined in.</param>
        /// <param name="typeName">The name of the component type to activate</param>
        /// <param name="activationFactory">The activation factory</param>
        public unsafe static int GetActivationFactory(
            char *componentPath,
            [MarshalAs(UnmanagedType.HString)] string typeName,
            [MarshalAs(UnmanagedType.Interface)] out IActivationFactory activationFactory)
        {
            activationFactory = null;
            try
            {
                if (typeName is null)
                {
                    throw new ArgumentNullException(nameof(typeName));
                }

                AssemblyLoadContext context = GetALC(Marshal.PtrToStringUni((IntPtr)componentPath));

                Type winRTType = context.LoadTypeForWinRTTypeNameInContext(typeName);

                if (winRTType is null || !winRTType.IsExportedToWindowsRuntime)
                {
                    throw new TypeLoadException(typeName);
                }
                activationFactory = WindowsRuntimeMarshal.GetManagedActivationFactory(winRTType);
            }
            catch (Exception ex)
            {
                return(ex.HResult);
            }
            return(0);
        }