EllanJiang/GameFramework · error · GameFrameworkException

Can not load binary ' ' from file system which is not a…

Error message

Can not load binary '{0}' from file system which is not a binary asset.

What it means

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.

Solutions

  1. Repackage with the file configured as a binary resource in the resource editor.
  2. If the resource is intentionally a normal asset, use LoadAsset instead of the binary APIs.
  3. Verify the resource name refers to the intended binary, not a same-named normal asset.
  4. Guard with a try-catch for GameFrameworkException and route to the appropriate loader by resource type.

Example fix

// before
byte[] bytes = m_ResourceComponent.LoadBinaryFromFileSystem("Data/table"); // packaged as normal asset
// after
// mark Data/table as binary resource in the resource editor, rebuild, then:
byte[] bytes = m_ResourceComponent.LoadBinaryFromFileSystem("Data/table");
Defensive patterns

Strategy: validation

Validate before calling

if (!BinaryResourceManifest.Contains(binaryName))
{
    Log.Warning("'{0}' is not a binary resource; falling back to LoadAsset.", binaryName);
    LoadAsNormalAsset(binaryName);
    return;
}

Type guard

bool IsBinaryLoadable(string name) => BinaryResourceManifest.Contains(name);

Try / catch

try { bytes = m_ResourceComponent.LoadBinaryFromFileSystem(binaryName); }
catch (GameFrameworkException ex) when (ex.Message.Contains("not a binary asset"))
{ LoadAsNormalAsset(binaryName); }

Prevention

When it happens

Trigger: Calling LoadBinaryFromFileSystem on a resource whose LoadType is not LoadFromBinary/LoadFromBinaryAndDecrypt/LoadFromBinaryAndQuickDecrypt — i.e. an asset packaged as a normal asset.

Common situations: 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.

Understand the failure class

Background: "is not a compatible type" / "cannot merge" errors: when a value's type doesn't match what the library requires — this error's family across 65 libraries.

Related errors


AI-assisted analysis of EllanJiang/GameFramework@d0c010b051 (2026-09-15). Data as JSON: /api/errors/643b8c8d7f9efd92. Report an issue: GitHub.

Appendix: source

Thrown at GameFramework/Resource/ResourceManager.ResourceLoader.cs:633

            /// </summary>
            /// <param name="binaryAssetName">要加载二进制资源的名称。</param>
            /// <returns>存储加载二进制资源的二进制流。</returns>
            public byte[] LoadBinaryFromFileSystem(string binaryAssetName)
            {
                ResourceInfo resourceInfo = GetResourceInfo(binaryAssetName);
                if (resourceInfo == null)
                {
                    throw new GameFrameworkException(Utility.Text.Format("Can not load binary '{0}' from file system which is not exist.", binaryAssetName));
                }

                if (!resourceInfo.Ready)
                {
                    throw new GameFrameworkException(Utility.Text.Format("Can not load binary '{0}' from file system which is not ready.", binaryAssetName));
                }

                if (!resourceInfo.IsLoadFromBinary)
                {
                    throw new GameFrameworkException(Utility.Text.Format("Can not load binary '{0}' from file system which is not a binary asset.", binaryAssetName));
                }

                if (!resourceInfo.UseFileSystem)
                {
                    throw new GameFrameworkException(Utility.Text.Format("Can not load binary '{0}' from file system which is not use file system.", binaryAssetName));
                }

                IFileSystem fileSystem = m_ResourceManager.GetFileSystem(resourceInfo.FileSystemName, resourceInfo.StorageInReadOnly);
                byte[] bytes = fileSystem.ReadFile(resourceInfo.ResourceName.FullName);
                if (bytes == null)
                {
                    return null;
                }

                if (resourceInfo.LoadType == LoadType.LoadFromBinaryAndQuickDecrypt || resourceInfo.LoadType == LoadType.LoadFromBinaryAndDecrypt)
                {
                    DecryptResourceCallback decryptResourceCallback = m_ResourceManager.m_DecryptResourceCallback ?? DefaultDecryptResourceCallback;
                    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);

View on GitHub (pinned to d0c010b051)