{"record":{"id":"740a830b5d7f944a","repo":"EllanJiang/GameFramework","slug":"can-not-load-binary-0-from-file-system-which-is-not-exist","errorCode":null,"errorMessage":"Can not load binary '{0}' from file system which is not exist.","messagePattern":"Can not load binary '(.+?)' from file system which is not exist\\.","errorType":"exception","errorClass":"GameFrameworkException","httpStatus":null,"severity":"error","filePath":"GameFramework/Resource/ResourceManager.ResourceLoader.cs","lineNumber":623,"sourceCode":"                }\n                else\n                {\n                    string path = Utility.Path.GetRemotePath(Path.Combine(resourceInfo.StorageInReadOnly ? m_ResourceManager.m_ReadOnlyPath : m_ResourceManager.m_ReadWritePath, resourceInfo.ResourceName.FullName));\n                    m_ResourceManager.m_ResourceHelper.LoadBytes(path, m_LoadBytesCallbacks, LoadBinaryInfo.Create(binaryAssetName, resourceInfo, loadBinaryCallbacks, userData));\n                }\n            }\n\n            /// <summary>\n            /// 从文件系统中加载二进制资源。\n            /// </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);","sourceCodeStart":605,"sourceCodeEnd":641,"githubUrl":"https://github.com/EllanJiang/GameFramework/blob/d0c010b05167c58e92350449d04864a91ca13fd2/GameFramework/Resource/ResourceManager.ResourceLoader.cs#L605-L641","documentation":"The synchronous LoadBinaryFromFileSystem looks up ResourceInfo for the binary asset; if it is null (the name is not in the resource index) it immediately throws a GameFrameworkException. Unlike LoadBinary, this API is synchronous and always throws — there is no failure callback path.","triggerScenarios":"Calling LoadBinaryFromFileSystem (either overload) with a binaryAssetName that has no ResourceInfo: name never packaged, misspelled, or resource metadata not initialized yet.","commonSituations":"Typos in asset names; loading before resource initialization completes; binary removed from the package in a newer build while an old caller still requests it.","solutions":["Verify the binary is packaged and the name matches exactly (case included) what is in the resource list.","Call only after resource initialization (InitResources) has populated the resource infos.","Use the async LoadBinary with failure callback if existence is uncertain, then LoadBinaryFromFileSystem only when confirmed present.","Wrap the call in try-catch for GameFrameworkException and fall back to re-checking the manifest."],"exampleFix":"// before\nbyte[] bytes = m_ResourceComponent.LoadBinaryFromFileSystem(\"cfg/data\"); // never packaged\n// after\nif (m_ResourceComponent.HasBinaryAsset(\"Data/cfg.dat\"))\n    byte[] bytes = m_ResourceComponent.LoadBinaryFromFileSystem(\"Data/cfg.dat\");","handlingStrategy":"try-catch","validationCode":"if (string.IsNullOrEmpty(binaryName) || !m_ResourceComponent.CheckBinaryAsset(binaryName))\n{\n    Log.Warning(\"Binary '{0}' not present in resource index.\", binaryName);\n    return null;\n}","typeGuard":"bool CanReadFromFileSystem(string name) => !string.IsNullOrEmpty(name) && m_ResourceComponent.CheckBinaryAsset(name);","tryCatchPattern":"byte[] bytes;\ntry { bytes = m_ResourceComponent.LoadBinaryFromFileSystem(binaryName); }\ncatch (GameFrameworkException ex) when (ex.Message.Contains(\"not exist\"))\n{ Log.Error(\"Binary {0} not packaged.\", binaryName); bytes = null; }","preventionTips":["Only call the synchronous API after resource initialization completed.","Validate names against a generated manifest of packaged binaries.","Prefer the async LoadBinary with failure callback when existence is uncertain.","Log the exact name compared against the resource list when debugging."],"tags":["gameframework","resource","filesystem","binary","not-exist"],"backgroundTag":"resource-not-found","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"}