EllanJiang/GameFramework · error · GameFrameworkException

You must get a Game Framework module, but

Error message

You must get a Game Framework module, but '{0}' is not.

What it means

GameFrameworkEntry.GetModule<T>() resolves the concrete module class from a module interface by naming convention: the concrete type must live in the same namespace with the leading 'I' stripped from the interface name, and the interface's full name must start with 'GameFramework.'. This error is thrown when the passed interface type is not a Game Framework type, i.e. its FullName does not begin with the 'GameFramework.' prefix, so module resolution cannot proceed.

Solutions

  1. Declare the module interface in a namespace starting with 'GameFramework.' (e.g. 'GameFramework.MyModule.IMyModule') or use a built-in interface such as GameFramework.IObjectPoolManager
  2. Verify with typeof(T).FullName.StartsWith("GameFramework.") before calling GetModule
  3. If you intended a custom module, register/obtain it through your own module system instead of GameFrameworkEntry

Example fix

// before
var module = GameFrameworkEntry.GetModule<IMyModule>(); // MyGame namespace
// after
namespace GameFramework.MyModule { public interface IMyModule : GameFramework.IGameFrameworkModule { } }
var module = GameFrameworkEntry.GetModule<GameFramework.MyModule.IMyModule>();
Defensive patterns

Strategy: validation

Validate before calling

if (typeof(T).IsInterface && typeof(T).FullName.StartsWith("GameFramework.", StringComparison.Ordinal))
{
    var module = GameFrameworkEntry.GetModule<T>();
}

Type guard

static bool IsGameFrameworkModuleInterface<T>() => typeof(T).IsInterface && typeof(T).FullName != null && typeof(T).FullName.StartsWith("GameFramework.", StringComparison.Ordinal);

Try / catch

try { var m = GameFrameworkEntry.GetModule<T>(); }
catch (GameFrameworkException ex) { Debug.LogError($"{typeof(T).FullName} is not a GameFramework module interface: {ex.Message}"); }

Prevention

When it happens

Trigger: Calling GameFrameworkEntry.GetModule<T>() where T is an interface whose full type name does not start with 'GameFramework.' — e.g. a custom module interface declared under a user namespace like 'MyGame.IMyModule', or accidentally passing a non-module interface.

Common situations: Developers creating their own custom module interfaces outside the GameFramework namespace; typos or renamed namespaces after moving code; passing an unrelated interface by mistake to GetModule.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


AI-assisted analysis of EllanJiang/GameFramework@d0c010b051 (2026-09-15). Data as JSON: /api/errors/1d7bf623695a0942. Report an issue: GitHub.

Appendix: source

Thrown at GameFramework/Base/GameFrameworkEntry.cs:65

        }

        /// <summary>
        /// 获取游戏框架模块。
        /// </summary>
        /// <typeparam name="T">要获取的游戏框架模块类型。</typeparam>
        /// <returns>要获取的游戏框架模块。</returns>
        /// <remarks>如果要获取的游戏框架模块不存在,则自动创建该游戏框架模块。</remarks>
        public static T GetModule<T>() where T : class
        {
            Type interfaceType = typeof(T);
            if (!interfaceType.IsInterface)
            {
                throw new GameFrameworkException(Utility.Text.Format("You must get module by interface, but '{0}' is not.", interfaceType.FullName));
            }

            if (!interfaceType.FullName.StartsWith("GameFramework.", StringComparison.Ordinal))
            {
                throw new GameFrameworkException(Utility.Text.Format("You must get a Game Framework module, but '{0}' is not.", interfaceType.FullName));
            }

            string moduleName = Utility.Text.Format("{0}.{1}", interfaceType.Namespace, interfaceType.Name.Substring(1));
            Type moduleType = Type.GetType(moduleName);
            if (moduleType == null)
            {
                throw new GameFrameworkException(Utility.Text.Format("Can not find Game Framework module type '{0}'.", moduleName));
            }

            return GetModule(moduleType) as T;
        }

        /// <summary>
        /// 获取游戏框架模块。
        /// </summary>
        /// <param name="moduleType">要获取的游戏框架模块类型。</param>
        /// <returns>要获取的游戏框架模块。</returns>
        /// <remarks>如果要获取的游戏框架模块不存在,则自动创建该游戏框架模块。</remarks>

View on GitHub (pinned to d0c010b051)