{"record":{"id":"643b8c8d7f9efd92","repo":"EllanJiang/GameFramework","slug":"can-not-load-binary-0-from-file-system-which-is-not-a-binary","errorCode":null,"errorMessage":"Can not load binary '{0}' from file system which is not a binary asset.","messagePattern":"Can not load binary '(.+?)' from file system which is not a binary asset\\.","errorType":"exception","errorClass":"GameFrameworkException","httpStatus":null,"severity":"error","filePath":"GameFramework/Resource/ResourceManager.ResourceLoader.cs","lineNumber":633,"sourceCode":"            /// </summary>\n            /// <param name=\"binaryAssetName\">要加载二进制资源的名称。</param>\n            /// <returns>存储加载二进制资源的二进制流。</returns>\n            public byte[] LoadBinaryFromFileSystem(string binaryAssetName)\n            {\n                ResourceInfo resourceInfo = GetResourceInfo(binaryAssetName);\n                if (resourceInfo == null)\n                {\n                    throw new GameFrameworkException(Utility.Text.Format(\"Can not load binary '{0}' from file system which is not exist.\", binaryAssetName));\n                }\n\n                if (!resourceInfo.Ready)\n                {\n                    throw new GameFrameworkException(Utility.Text.Format(\"Can not load binary '{0}' from file system which is not ready.\", binaryAssetName));\n                }\n\n                if (!resourceInfo.IsLoadFromBinary)\n                {\n                    throw new GameFrameworkException(Utility.Text.Format(\"Can not load binary '{0}' from file system which is not a binary asset.\", binaryAssetName));\n                }\n\n                if (!resourceInfo.UseFileSystem)\n                {\n                    throw new GameFrameworkException(Utility.Text.Format(\"Can not load binary '{0}' from file system which is not use file system.\", binaryAssetName));\n                }\n\n                IFileSystem fileSystem = m_ResourceManager.GetFileSystem(resourceInfo.FileSystemName, resourceInfo.StorageInReadOnly);\n                byte[] bytes = fileSystem.ReadFile(resourceInfo.ResourceName.FullName);\n                if (bytes == null)\n                {\n                    return null;\n                }\n\n                if (resourceInfo.LoadType == LoadType.LoadFromBinaryAndQuickDecrypt || resourceInfo.LoadType == LoadType.LoadFromBinaryAndDecrypt)\n                {\n                    DecryptResourceCallback decryptResourceCallback = m_ResourceManager.m_DecryptResourceCallback ?? DefaultDecryptResourceCallback;\n                    decryptResourceCallback(bytes, 0, bytes.Length, resourceInfo.ResourceName.Name, resourceInfo.ResourceName.Variant, resourceInfo.ResourceName.Extension, resourceInfo.StorageInReadOnly, resourceInfo.FileSystemName, (byte)resourceInfo.LoadType, resourceInfo.Length, resourceInfo.HashCode);","sourceCodeStart":615,"sourceCodeEnd":651,"githubUrl":"https://github.com/EllanJiang/GameFramework/blob/d0c010b05167c58e92350449d04864a91ca13fd2/GameFramework/Resource/ResourceManager.ResourceLoader.cs#L615-L651","documentation":"The resource exists and is ready, but ResourceInfo.IsLoadFromBinary is false: it was packaged as a regular asset, not a binary asset, so it cannot be read through the binary file-system path. The method throws a GameFrameworkException.","triggerScenarios":"Calling LoadBinaryFromFileSystem on a resource whose LoadType is not LoadFromBinary/LoadFromBinaryAndDecrypt/LoadFromBinaryAndQuickDecrypt — i.e. an asset packaged as a normal asset.","commonSituations":"Mixing up names of normal assets and binary assets in the package; resource type changed in the resource editor between builds while code still treats it as binary.","solutions":["Repackage with the file configured as a binary resource in the resource editor.","If the resource is intentionally a normal asset, use LoadAsset instead of the binary APIs.","Verify the resource name refers to the intended binary, not a same-named normal asset.","Guard with a try-catch for GameFrameworkException and route to the appropriate loader by resource type."],"exampleFix":"// before\nbyte[] bytes = m_ResourceComponent.LoadBinaryFromFileSystem(\"Data/table\"); // packaged as normal asset\n// after\n// mark Data/table as binary resource in the resource editor, rebuild, then:\nbyte[] bytes = m_ResourceComponent.LoadBinaryFromFileSystem(\"Data/table\");","handlingStrategy":"validation","validationCode":"if (!BinaryResourceManifest.Contains(binaryName))\n{\n    Log.Warning(\"'{0}' is not a binary resource; falling back to LoadAsset.\", binaryName);\n    LoadAsNormalAsset(binaryName);\n    return;\n}","typeGuard":"bool IsBinaryLoadable(string name) => BinaryResourceManifest.Contains(name);","tryCatchPattern":"try { bytes = m_ResourceComponent.LoadBinaryFromFileSystem(binaryName); }\ncatch (GameFrameworkException ex) when (ex.Message.Contains(\"not a binary asset\"))\n{ LoadAsNormalAsset(binaryName); }","preventionTips":["Keep a generated binary-resource manifest and derive calls from it.","Diff resource packaging settings between builds in CI.","Do not assume every packaged file is a binary asset.","Route loading through a helper that picks LoadAsset vs LoadBinary by type."],"tags":["gameframework","resource","filesystem","binary","type-error"],"backgroundTag":"incompatible-source-type","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"}