babalae/better-genshin-impact · critical · FileNotFoundException

未找到物品 ONNX 配套表格。

Error message

未找到物品 ONNX 配套表格。

What it means

Thrown as FileNotFoundException by LoadWeaponNames when File.Exists(path) is false at the expected asset path (Assets/Model/ItemV2/item.csv resolved via Global.Absolute). The weapon name matcher lazily loads this CSV on first use; if the file is absent the entire weapon OCR correction pipeline cannot initialize.

Source

Thrown at BetterGenshinImpact/GameTask/CharacterDevelopment/WeaponNameMatcher.cs:171

            {
                var substitutionCost = source[sourceIndex - 1] == target[targetIndex - 1] ? 0 : 1;
                current[sourceIndex] = Math.Min(
                    Math.Min(current[sourceIndex - 1] + 1, previous[sourceIndex] + 1),
                    previous[sourceIndex - 1] + substitutionCost);
            }

            (previous, current) = (current, previous);
        }

        return previous[source.Length];
    }

    private static IReadOnlyList<string> LoadWeaponNames()
    {
        var path = Global.Absolute(WeaponPrototypePath);
        if (!File.Exists(path))
        {
            throw new FileNotFoundException("未找到物品 ONNX 配套表格。", path);
        }

        using var parser = new TextFieldParser(path, Encoding.UTF8)
        {
            TextFieldType = FieldType.Delimited,
            HasFieldsEnclosedInQuotes = true,
            TrimWhiteSpace = false
        };
        parser.SetDelimiters(",");
        var headers = parser.ReadFields()
                      ?? throw new InvalidDataException("物品原型表缺少表头。");
        var rows = new List<string[]>();
        while (!parser.EndOfData)
        {
            rows.Add(parser.ReadFields()
                     ?? throw new InvalidDataException("物品原型表存在无法读取的记录。"));
        }

View on GitHub (pinned to a7cb36712d)

Solutions

  1. Confirm Assets/Model/ItemV2/item.csv exists relative to the application base directory.
  2. Check the .csproj has the file marked CopyToOutputDirectory and that the build actually copied it.
  3. If the file was deleted, reinstall or rebuild the project.

Example fix

null
Defensive patterns

Strategy: validation

Validate before calling

var path = Global.Absolute(@"Assets\Model\ItemV2\item.csv");
if (!File.Exists(path)) { /* alert user: missing asset, abort weapon matching */ }

Type guard

null

Try / catch

try { WeaponNameMatcher.Match(text); }
catch (FileNotFoundException ex) { /* log missing file path, prompt reinstall */ }

Prevention

When it happens

Trigger: First call to WeaponNameMatcher.Match() when item.csv is missing from the deployment directory, or Global.Absolute resolves to an unexpected base directory.

Common situations: The application was deployed without copying Assets to the output directory. A build script excluded large asset files. The working directory or Global.Absolute base path was changed. The user deleted the asset folder.

Related errors


AI-assisted analysis of babalae/better-genshin-impact@a7cb36712d (2026-08-13). Data as JSON: /api/errors/1f988da27948fcc8. Report an issue: GitHub.