{"record":{"id":"bbda6618d51b0c3b","repo":"JosefNemec/Playnite","slug":"emulator-emulator-builtinconfigid-and-profile-p","errorCode":null,"errorMessage":"Emulator {emulator.BuiltInConfigId} and profile {profile.BuiltInProfileName} not found.","messagePattern":"Emulator (.+?) and profile (.+?) not found\\.","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"source/Playnite/Emulators/Scanner.cs","lineNumber":535,"sourceCode":"\r\n            return matches;\r\n        }\r\n\r\n        private List<ScannedGame> ScanDirectory(\r\n            string directory,\r\n            Emulator emulator,\r\n            BuiltInEmulatorProfile profile,\r\n            CancellationToken cancelToken,\r\n            string crcExludePatterns,\r\n            bool scanSubfolders,\r\n            bool scanArchives,\r\n            bool mergeRelatedFiles,\r\n            Action<string> fileScanCallback = null)\r\n        {\r\n            var emuProf = Emulation.GetProfile(emulator.BuiltInConfigId, profile.BuiltInProfileName);\r\n            if (emuProf == null)\r\n            {\r\n                throw new Exception($\"Emulator {emulator.BuiltInConfigId} and profile {profile.BuiltInProfileName} not found.\");\r\n            }\r\n\r\n            if (emuProf.ScriptGameImport)\r\n            {\r\n                object scannedGames = null;\r\n                Exception failExc = null;\r\n                var importRuntime = new PowerShellRuntime(\"Emu game import\");\r\n                var scriptTask = Task.Run(() =>\r\n                {\r\n                    try\r\n                    {\r\n                        scannedGames = importRuntime.ExecuteFile(\r\n                            Emulation.GetGameImportScriptPath(Emulation.GetDefition(emulator.BuiltInConfigId)),\r\n                            emulator.InstallDir,\r\n                            new Dictionary<string, object>\r\n                            {\r\n                                { \"CancelToken\", cancelToken },\r\n                                { \"Emulator\", emulator },\r","sourceCodeStart":517,"sourceCodeEnd":553,"githubUrl":"https://github.com/JosefNemec/Playnite/blob/5911f4e964e628aa7a69c2030ab35101afa63067/source/Playnite/Emulators/Scanner.cs#L517-L553","documentation":"Thrown when ScanDirectory is called with a BuiltInEmulatorProfile whose (emulator.BuiltInConfigId, profile.BuiltInProfileName) pair resolves to no EmulatorDefinitionProfile via Emulation.GetProfile. Unlike error 60, this path is reached when scanning is initiated directly with a profile object (the BuiltInEmulatorProfiles editor flow), so the emulator definition itself is the missing piece.","triggerScenarios":"Calling the ScanDirectory overload taking BuiltInEmulatorProfile profile where Emulation.GetProfile(emulator.BuiltInConfigId, profile.BuiltInProfileName) returns null. The definition name on the profile does not match any profile in the loaded definition for that emulator id.","commonSituations":"Built-in emulator definitions were updated/renamed but a saved profile still references the old BuiltInProfileName; BuiltInConfigId is null because the emulator record was never assigned a built-in definition; definition files failed to deserialize at startup.","solutions":["Confirm Emulation.GetDefinition(emulator.BuiltInConfigId) returns a definition with a Profile whose Name equals profile.BuiltInProfileName before scanning.","Recreate the built-in profile so BuiltInProfileName aligns with the current definition.","Validate that built-in emulator definition files shipped with Playnite are present and parseable."],"exampleFix":"// before\nvar emuProf = Emulation.GetProfile(emulator.BuiltInConfigId, profile.BuiltInProfileName);\nif (emuProf == null) { throw new Exception($\"Emulator {emulator.BuiltInConfigId} and profile {profile.BuiltInProfileName} not found.\"); }\n\n// after\nvar emuProf = Emulation.GetProfile(emulator.BuiltInConfigId, profile.BuiltInProfileName);\nif (emuProf == null) {\n    throw new Exception($\"Emulator definition '{emulator.BuiltInConfigId}' has no profile named '{profile.BuiltInProfileName}'. Available: {string.Join(\", \", Emulation.GetDefition(emulator.BuiltInConfigId)?.Profiles?.Select(p => p.Name) ?? Enumerable.Empty<string>())}\");\n}","handlingStrategy":"validation","validationCode":"// Verify definition/profile pair resolves before scanning with a BuiltInEmulatorProfile.\nif (Emulation.GetProfile(emulator.BuiltInConfigId, profile.BuiltInProfileName) == null) {\n    logger.Warn($\"No definition for {emulator.BuiltInConfigId}/{profile.BuiltInProfileName}\");\n    return;\n}","typeGuard":"static bool BuiltInProfileResolves(Emulator emu, BuiltInEmulatorProfile p) =>\n    Emulation.GetProfile(emu.BuiltInConfigId, p.BuiltInProfileName) != null;","tryCatchPattern":null,"preventionTips":["Keep built-in definition files in sync with Playnite version.","Validate BuiltInConfigId is non-null when creating emulators.","Log available profile names when resolution fails to speed diagnosis."],"tags":["emulator","scanner","configuration","null-check"],"backgroundTag":null,"analyzedSha":"5911f4e964e628aa7a69c2030ab35101afa63067","analyzedAt":"2026-08-13T17:38:25.713Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}