{"record":{"id":"3debdb44dbdc9a51","repo":"babalae/better-genshin-impact","slug":"featname-assertname","errorCode":null,"errorMessage":"未找到{featName}中的{assertName}文件","messagePattern":"未找到(.+?)中的(.+?)文件","errorType":"exception","errorClass":"FileNotFoundException","httpStatus":null,"severity":"error","filePath":"BetterGenshinImpact/GameTask/GameTaskManager.cs","lineNumber":170,"sourceCode":"    /// <returns></returns>\n    /// <exception cref=\"FileNotFoundException\"></exception>\n    public static Mat LoadAssetImage(string featName, string assertName, ISystemInfo systemInfo, ImreadModes flags = ImreadModes.Color)\n    {\n        var assetsFolder = Global.Absolute($@\"GameTask\\{featName}\\Assets\\{systemInfo.GameScreenSize.Width}x{systemInfo.GameScreenSize.Height}\");\n        if (!Directory.Exists(assetsFolder))\n        {\n            assetsFolder = Global.Absolute($@\"GameTask\\{featName}\\Assets\\1920x1080\");\n        }\n\n        if (!Directory.Exists(assetsFolder))\n        {\n            throw new FileNotFoundException($\"未找到{featName}的素材文件夹\");\n        }\n\n        var filePath = Path.Combine(assetsFolder, assertName);\n        if (!File.Exists(filePath))\n        {\n            throw new FileNotFoundException($\"未找到{featName}中的{assertName}文件\");\n        }\n\n        var mat = Mat.FromStream(File.OpenRead(filePath), flags);\n        if (systemInfo.GameScreenSize.Width != 1920)\n        {\n            mat = ResizeHelper.Resize(mat, systemInfo.AssetScale);\n        }\n\n        return mat;\n    }\n\n    /// <summary>\n    /// 根据捕获区域宽高加载素材图片并缩放\n    /// </summary>\n    /// <returns></returns>\n    /// <exception cref=\"FileNotFoundException\"></exception>\n    public static Mat LoadAssetImage(string featName, string assertName, int captureWidth, int captureHeight, ImreadModes flags = ImreadModes.Color)\n    {","sourceCodeStart":152,"sourceCodeEnd":188,"githubUrl":"https://github.com/babalae/better-genshin-impact/blob/a7cb36712dcb409be610257d877fcea3597e9d6b/BetterGenshinImpact/GameTask/GameTaskManager.cs#L152-L188","documentation":"Thrown by GameTaskManager.LoadAssetImage when the Assets folder exists (either resolution-specific or the 1920x1080 fallback) but the individual asset file named assertName is not found inside it. The path is constructed via Path.Combine(assetsFolder, assertName), so a missing file or an incorrect filename triggers this.","triggerScenarios":"Calling LoadAssetImage with an assertName that does not exist in the resolved Assets folder. Common causes: filename typo, wrong file extension (e.g. .jpg vs .png), case mismatch, or the asset was never generated/copied.","commonSituations":"A developer adds a new recognition template reference but forgets to add the corresponding image file; an asset was renamed in code but not on disk; cross-platform case-sensitivity issues when developing on Linux but shipping on Windows.","solutions":["Check the exact filename and extension in the resolved Assets folder and compare against assertName.","Log the full constructed filePath to confirm which folder was resolved (resolution-specific vs fallback).","Ensure all referenced asset files are included in the .csproj as Content with CopyToOutputDirectory.","Add a File.Exists guard at the call site with a helpful error message listing available files in the folder."],"exampleFix":"// before\nvar filePath = Path.Combine(assetsFolder, assertName);\nif (!File.Exists(filePath))\n    throw new FileNotFoundException($\"未找到{featName}中的{assertName}文件\");\n\n// after\nvar filePath = Path.Combine(assetsFolder, assertName);\nif (!File.Exists(filePath))\n    throw new FileNotFoundException(\n        $\"未找到{featName}中的{assertName}文件，路径：{filePath}，\" +\n        $\"目录内文件：{string.Join(\", \", Directory.GetFiles(assetsFolder).Select(Path.GetFileName))}\",\n        filePath);","handlingStrategy":"validation","validationCode":"var filePath = Path.Combine(fallbackFolder, assertName);\nif (!File.Exists(filePath))\n{\n    logger.LogError(\"素材文件不存在：{Path}\", filePath);\n    return;\n}","typeGuard":null,"tryCatchPattern":"try { var mat = GameTaskManager.LoadAssetImage(featName, assertName, systemInfo); }\ncatch (FileNotFoundException ex) when (ex.Message.Contains(assertName))\n{ logger.LogError(ex, \"文件缺失：{File}\", assertName); }","preventionTips":["Keep a manifest of expected asset files per task and validate at startup.","Include assets as Content in .csproj with CopyToOutputDirectory.","Use nameof or constants for asset filenames to avoid typos."],"tags":["file-not-found","assets","game-task"],"backgroundTag":null,"analyzedSha":"a7cb36712dcb409be610257d877fcea3597e9d6b","analyzedAt":"2026-08-13T16:44:57.548Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}