{"record":{"id":"a436c0c67b6cfe23","repo":"EllanJiang/GameFramework","slug":"entity-asset-is-invalid","errorCode":null,"errorMessage":"Entity asset is invalid.","messagePattern":"Entity asset is invalid\\.","errorType":"exception","errorClass":"GameFrameworkException","httpStatus":null,"severity":"error","filePath":"GameFramework/Entity/EntityManager.EntityInstanceObject.cs","lineNumber":32,"sourceCode":"        /// <summary>\n        /// 实体实例对象。\n        /// </summary>\n        private sealed class EntityInstanceObject : ObjectBase\n        {\n            private object m_EntityAsset;\n            private IEntityHelper m_EntityHelper;\n\n            public EntityInstanceObject()\n            {\n                m_EntityAsset = null;\n                m_EntityHelper = null;\n            }\n\n            public static EntityInstanceObject Create(string name, object entityAsset, object entityInstance, IEntityHelper entityHelper)\n            {\n                if (entityAsset == null)\n                {\n                    throw new GameFrameworkException(\"Entity asset is invalid.\");\n                }\n\n                if (entityHelper == null)\n                {\n                    throw new GameFrameworkException(\"Entity helper is invalid.\");\n                }\n\n                EntityInstanceObject entityInstanceObject = ReferencePool.Acquire<EntityInstanceObject>();\n                entityInstanceObject.Initialize(name, entityInstance);\n                entityInstanceObject.m_EntityAsset = entityAsset;\n                entityInstanceObject.m_EntityHelper = entityHelper;\n                return entityInstanceObject;\n            }\n\n            public override void Clear()\n            {\n                base.Clear();\n                m_EntityAsset = null;","sourceCodeStart":14,"sourceCodeEnd":50,"githubUrl":"https://github.com/EllanJiang/GameFramework/blob/d0c010b05167c58e92350449d04864a91ca13fd2/GameFramework/Entity/EntityManager.EntityInstanceObject.cs#L14-L50","documentation":"EntityInstanceObject.Create builds the pooled object that pairs an entity asset with its instance and helper. It throws GameFrameworkException when the entityAsset argument is null, since the pooled object exists to hold that asset reference. Raised during entity show flows when the loaded asset is missing.","triggerScenarios":"Calling EntityInstanceObject.Create(name, null, entityInstance, entityHelper) directly, or ShowEntity flow where the asset loaded from the entity table was null (failed/missing AssetObject).","commonSituations":"Entity asset name not present in resource/asset configuration; asset load failed but null was propagated instead of surfacing the load error; custom derived EntityManager supplying null assets.","solutions":["Ensure the entity asset is loaded and non-null before creating the instance object.","Check the entity info table: the asset name must exist in your resource package.","Verify the asset load completed (load dependency/callback) before showing the entity.","Null-check entityAsset if you call Create from custom code."],"exampleFix":"// before\nvar obj = EntityInstanceObject.Create(name, entityAsset, instance, helper);\n// after\nif (entityAsset == null) throw new InvalidOperationException(\"Entity asset not loaded: \" + name);\nvar obj = EntityInstanceObject.Create(name, entityAsset, instance, helper);","handlingStrategy":"validation","validationCode":"if (entityAsset == null) throw new InvalidOperationException(\"Entity asset not loaded: \" + name);\nvar obj = EntityInstanceObject.Create(name, entityAsset, entityInstance, entityHelper);","typeGuard":"bool HasAsset(object entityAsset) => entityAsset != null;","tryCatchPattern":"try { var obj = EntityInstanceObject.Create(name, entityAsset, instance, helper); }\ncatch (GameFrameworkException ex) { Log.Error(\"Instance object create failed: {0}\", ex.Message); }","preventionTips":["Wait for asset load completion before showing entities","Validate entity table asset names against your resource package","Never propagate null assets from failed loads; surface load errors instead"],"tags":["csharp","gameframework","null-argument","asset"],"backgroundTag":"null-argument","analyzedSha":"d0c010b05167c58e92350449d04864a91ca13fd2","analyzedAt":"2026-09-15T13:37:15.352Z","contentChangedAt":"2026-09-15T13:37:15.352Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}