{"record":{"id":"467494eb5a0bd467","repo":"JosefNemec/Playnite","slug":"emulator-not-found-467494","errorCode":null,"errorMessage":"Emulator not found.","messagePattern":"Emulator not found\\.","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"source/Playnite/GamesEditor.cs","lineNumber":444,"sourceCode":"            try\r\n            {\r\n                switch (action.Type)\r\n                {\r\n                    case GameActionType.URL:\r\n                        ProcessStarter.StartUrl(action.Path);\r\n                        break;\r\n                    case GameActionType.File:\r\n                    case GameActionType.Emulator:\r\n                    case GameActionType.Script:\r\n                        using (var scriptRuntime = new PowerShellRuntime(\"Custom action runtime\"))\r\n                        using (var controller = new GenericPlayController(Database, game, scriptRuntime, Application.PlayniteApiGlobal))\r\n                        {\r\n                            if (action.Type == GameActionType.Emulator)\r\n                            {\r\n                                var emulator = Database.Emulators[action.EmulatorId];\r\n                                if (emulator == null)\r\n                                {\r\n                                    throw new Exception($\"Emulator not found.\");\r\n                                }\r\n\r\n                                var prof = emulator.AllProfiles.FirstOrDefault(a => a.Id == action.EmulatorProfileId);\r\n                                var newAction = action.GetClone<GameAction, EmulationPlayAction>();\r\n                                newAction.SelectedEmulatorProfile = prof ?? throw new Exception(\"Specified emulator config does't exists.\");\r\n                                newAction.SelectedRomPath = game.Roms.HasItems() ? game.Roms[0].Path : string.Empty;\r\n                                controller.StartEmulator(newAction, false, new SDK.Events.OnGameStartingEventArgs\r\n                                {\r\n                                    Game = game,\r\n                                    SelectedRomFile = newAction.SelectedRomPath,\r\n                                    SourceAction = action\r\n                                });\r\n                            }\r\n                            else\r\n                            {\r\n                                controller.Start(action, false,  new SDK.Events.OnGameStartingEventArgs\r\n                                {\r\n                                    Game = game,\r","sourceCodeStart":426,"sourceCodeEnd":462,"githubUrl":"https://github.com/JosefNemec/Playnite/blob/5911f4e964e628aa7a69c2030ab35101afa63067/source/Playnite/GamesEditor.cs#L426-L462","documentation":"Thrown by ActivateAction when a GameAction of type Emulator references an EmulatorId that no longer resolves to an emulator in Database.Emulators. The emulator record was deleted or its id changed after the action was saved, so the action's target emulator cannot be located.","triggerScenarios":"Activating an emulator-type GameAction where Database.Emulators[action.EmulatorId] returns null. The stored EmulatorId does not match any current emulator record — typically after the user deleted/recreated the emulator.","commonSituations":"User deleted an emulator from configuration but games still reference its id; an addon/migration rewrote emulator ids; database merge/import left dangling EmulatorId references on actions.","solutions":["Validate that Database.Emulators[action.EmulatorId] is non-null before activating the action.","Re-assign the game's emulator action to an existing emulator via the edit dialog.","Run a consistency check/repair to detect and clear dangling EmulatorId references."],"exampleFix":"// before\nvar emulator = Database.Emulators[action.EmulatorId];\nif (emulator == null) { throw new Exception($\"Emulator not found.\"); }\n\n// after — graceful user feedback\nvar emulator = Database.Emulators[action.EmulatorId];\nif (emulator == null) {\n    Dialogs.ShowMessage($\"The emulator assigned to this action no longer exists (id {action.EmulatorId}). Please reassign it.\", \"Emulator missing\", MessageBoxButton.OK, MessageBoxImage.Warning);\n    return;\n}","handlingStrategy":"validation","validationCode":"// Verify the emulator exists before activating an emulator action.\nif (Database.Emulators[action.EmulatorId] == null) {\n    Dialogs.ShowMessage(\"Assigned emulator no longer exists.\", \"Error\", MessageBoxButton.OK, MessageBoxImage.Warning);\n    return;\n}","typeGuard":"static bool EmulatorExists(IGameDatabase db, Guid id) => db.Emulators[id] != null;","tryCatchPattern":null,"preventionTips":["When deleting an emulator, also clear/flag game actions referencing it.","Run periodic referential-integrity checks on game actions.","Expose dangling references in the game edit dialog for manual repair."],"tags":["game-controller","emulator","database","dangling-reference"],"backgroundTag":null,"analyzedSha":"5911f4e964e628aa7a69c2030ab35101afa63067","analyzedAt":"2026-08-13T17:38:25.713Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}