{"record":{"id":"86e5f466ccbc8374","repo":"EllanJiang/GameFramework","slug":"can-not-find-game-framework-module-type-0","errorCode":null,"errorMessage":"Can not find Game Framework module type '{0}'.","messagePattern":"Can not find Game Framework module type '(.+?)'\\.","errorType":"exception","errorClass":"GameFrameworkException","httpStatus":null,"severity":"error","filePath":"GameFramework/Base/GameFrameworkEntry.cs","lineNumber":72,"sourceCode":"        /// <remarks>如果要获取的游戏框架模块不存在，则自动创建该游戏框架模块。</remarks>\n        public static T GetModule<T>() where T : class\n        {\n            Type interfaceType = typeof(T);\n            if (!interfaceType.IsInterface)\n            {\n                throw new GameFrameworkException(Utility.Text.Format(\"You must get module by interface, but '{0}' is not.\", interfaceType.FullName));\n            }\n\n            if (!interfaceType.FullName.StartsWith(\"GameFramework.\", StringComparison.Ordinal))\n            {\n                throw new GameFrameworkException(Utility.Text.Format(\"You must get a Game Framework module, but '{0}' is not.\", interfaceType.FullName));\n            }\n\n            string moduleName = Utility.Text.Format(\"{0}.{1}\", interfaceType.Namespace, interfaceType.Name.Substring(1));\n            Type moduleType = Type.GetType(moduleName);\n            if (moduleType == null)\n            {\n                throw new GameFrameworkException(Utility.Text.Format(\"Can not find Game Framework module type '{0}'.\", moduleName));\n            }\n\n            return GetModule(moduleType) as T;\n        }\n\n        /// <summary>\n        /// 获取游戏框架模块。\n        /// </summary>\n        /// <param name=\"moduleType\">要获取的游戏框架模块类型。</param>\n        /// <returns>要获取的游戏框架模块。</returns>\n        /// <remarks>如果要获取的游戏框架模块不存在，则自动创建该游戏框架模块。</remarks>\n        private static GameFrameworkModule GetModule(Type moduleType)\n        {\n            foreach (GameFrameworkModule module in s_GameFrameworkModules)\n            {\n                if (module.GetType() == moduleType)\n                {\n                    return module;","sourceCodeStart":54,"sourceCodeEnd":90,"githubUrl":"https://github.com/EllanJiang/GameFramework/blob/d0c010b05167c58e92350449d04864a91ca13fd2/GameFramework/Base/GameFrameworkEntry.cs#L54-L90","documentation":"GetModule<T>() builds the concrete module type name from the interface by convention ('Namespace.InterfaceNameWithoutI') and calls Type.GetType on it. When no such concrete class exists (or it is not loaded in the current assembly context), Type.GetType returns null and this error is thrown.","triggerScenarios":"Calling GameFrameworkEntry.GetModule<T>() where the matching concrete class (e.g. IMyModule -> MyModule) does not exist in the same namespace, has been renamed, lives in an assembly not loaded/resolvable by Type.GetType, or the interface name does not follow the I-prefix convention.","commonSituations":"Implementing a custom module interface but forgetting the concrete class; renaming the concrete class or namespace; Unity IL2CPP/assembly stripping removing the concrete type so Type.GetType fails; interface not following the 'I' prefix convention so the Substring(1) mangles the name.","solutions":["Create a concrete class named InterfaceName minus the leading 'I' in the same namespace as the interface, derived from GameFrameworkModule","Ensure the concrete class is in an assembly referenced/loaded at runtime (avoid IL2CPP code stripping of module types)","Verify the interface is named with the 'I' prefix (e.g. IFoo -> Foo); a non-I interface name produces a wrong type name"],"exampleFix":"// before\npublic interface GameFramework.MyModule.IMyModule { } // no concrete class\n// after\nnamespace GameFramework.MyModule\n{\n    public interface IMyModule : GameFramework.IGameFrameworkModule { }\n    internal sealed class MyModule : GameFrameworkModule, IMyModule { /* ... */ }\n}","handlingStrategy":"validation","validationCode":"string moduleName = typeof(T).Namespace + \".\" + typeof(T).Name.Substring(1);\nif (Type.GetType(moduleName) != null)\n{\n    var module = GameFrameworkEntry.GetModule<T>();\n}","typeGuard":"static bool HasConcreteModuleType<T>()\n{\n    var t = typeof(T);\n    return t.IsInterface && t.Name.StartsWith(\"I\") && Type.GetType($\"{t.Namespace}.{t.Name.Substring(1)}\") != null;\n}","tryCatchPattern":"try { var m = GameFrameworkEntry.GetModule<T>(); }\ncatch (GameFrameworkException ex) { Debug.LogError($\"Concrete type for {typeof(T)} not found: {ex.Message}\"); }","preventionTips":["Always pair each module interface with a same-namespace concrete class named without the 'I' prefix","Name interfaces with the 'I' prefix so the convention resolves correctly","Disable IL2CPP code stripping (link.xml preserve) for module assemblies so Type.GetType can find them"],"tags":["gameframework","module-lookup","type-resolution"],"backgroundTag":"class-not-found","analyzedSha":"d0c010b05167c58e92350449d04864a91ca13fd2","analyzedAt":"2026-09-15T13:37:15.352Z","contentChangedAt":"2026-09-15T13:37:15.352Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}