{"record":{"id":"bc0b7f964ac9e67f","repo":"EllanJiang/GameFramework","slug":"binary-asset-name-is-invalid","errorCode":null,"errorMessage":"Binary asset name is invalid.","messagePattern":"Binary asset name is invalid\\.","errorType":"validation","errorClass":"GameFrameworkException","httpStatus":null,"severity":"error","filePath":"GameFramework/Resource/ResourceManager.cs","lineNumber":1784,"sourceCode":"            if (unloadSceneCallbacks == null)\n            {\n                throw new GameFrameworkException(\"Unload scene callbacks is invalid.\");\n            }\n\n            m_ResourceLoader.UnloadScene(sceneAssetName, unloadSceneCallbacks, userData);\n        }\n\n        /// <summary>\n        /// 获取二进制资源的实际路径。\n        /// </summary>\n        /// <param name=\"binaryAssetName\">要获取实际路径的二进制资源的名称。</param>\n        /// <returns>二进制资源的实际路径。</returns>\n        /// <remarks>此方法仅适用于二进制资源存储在磁盘（而非文件系统）中的情况。若二进制资源存储在文件系统中时，返回值将始终为空。</remarks>\n        public string GetBinaryPath(string binaryAssetName)\n        {\n            if (string.IsNullOrEmpty(binaryAssetName))\n            {\n                throw new GameFrameworkException(\"Binary asset name is invalid.\");\n            }\n\n            return m_ResourceLoader.GetBinaryPath(binaryAssetName);\n        }\n\n        /// <summary>\n        /// 获取二进制资源的实际路径。\n        /// </summary>\n        /// <param name=\"binaryAssetName\">要获取实际路径的二进制资源的名称。</param>\n        /// <param name=\"storageInReadOnly\">二进制资源是否存储在只读区中。</param>\n        /// <param name=\"storageInFileSystem\">二进制资源是否存储在文件系统中。</param>\n        /// <param name=\"relativePath\">二进制资源或存储二进制资源的文件系统，相对于只读区或者读写区的相对路径。</param>\n        /// <param name=\"fileName\">若二进制资源存储在文件系统中，则指示二进制资源在文件系统中的名称，否则此参数返回空。</param>\n        /// <returns>是否获取二进制资源的实际路径成功。</returns>\n        public bool GetBinaryPath(string binaryAssetName, out bool storageInReadOnly, out bool storageInFileSystem, out string relativePath, out string fileName)\n        {\n            return m_ResourceLoader.GetBinaryPath(binaryAssetName, out storageInReadOnly, out storageInFileSystem, out relativePath, out fileName);\n        }","sourceCodeStart":1766,"sourceCodeEnd":1802,"githubUrl":"https://github.com/EllanJiang/GameFramework/blob/d0c010b05167c58e92350449d04864a91ca13fd2/GameFramework/Resource/ResourceManager.cs#L1766-L1802","documentation":"ResourceManager.GetBinaryPath validates binaryAssetName and throws this GameFrameworkException when it is null or empty. This method resolves the on-disk path of a binary resource (only applicable when binaries are stored on disk rather than packed file systems); an empty name cannot be resolved. The check precedes delegation to m_ResourceLoader.GetBinaryPath.","triggerScenarios":"Calling GetBinaryPath(string) with binaryAssetName null or \"\".","commonSituations":"Looking up a binary path before a load where the name variable was never assigned; config-driven binary asset lists with empty entries; path-building code that produced an empty string due to a failed format/combine.","solutions":["Pass the correct non-empty binary asset name","Validate the name source (config, UI, computed path) for empty values before the call","Remember GetBinaryPath only returns a real path for disk-stored binaries; if you actually want content, use LoadBinary instead"],"exampleFix":"// before\nstring path = resourceManager.GetBinaryPath(binaryName);\n// after\nif (string.IsNullOrEmpty(binaryName)) throw new ArgumentException(\"binaryName required\");\nstring path = resourceManager.GetBinaryPath(binaryName);","handlingStrategy":"validation","validationCode":"if (string.IsNullOrEmpty(binaryAssetName)) throw new ArgumentException(\"binaryAssetName required\", nameof(binaryAssetName));","typeGuard":null,"tryCatchPattern":"try { string path = resourceManager.GetBinaryPath(binaryAssetName); } catch (GameFrameworkException ex) { Log.Error(ex.Message); }","preventionTips":["Validate binary names from config or network payloads before lookup","Understand GetBinaryPath only works for disk-stored binaries; use LoadBinary for packed ones","Keep binary asset names as constants alongside their load calls"],"tags":["csharp","gameframework","empty-string","binary-resources"],"backgroundTag":"empty-required-field","analyzedSha":"d0c010b05167c58e92350449d04864a91ca13fd2","analyzedAt":"2026-09-15T13:37:15.352Z","contentChangedAt":"2026-09-15T13:37:15.352Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}