{"record":{"id":"c2c891c0c163a3ca","repo":"EllanJiang/GameFramework","slug":"debugger-window-is-invalid","errorCode":null,"errorMessage":"Debugger window is invalid.","messagePattern":"Debugger window is invalid\\.","errorType":"exception","errorClass":"GameFrameworkException","httpStatus":null,"severity":"error","filePath":"GameFramework/Debugger/DebuggerManager.cs","lineNumber":104,"sourceCode":"            m_DebuggerWindowRoot.Shutdown();\n        }\n\n        /// <summary>\n        /// 注册调试器窗口。\n        /// </summary>\n        /// <param name=\"path\">调试器窗口路径。</param>\n        /// <param name=\"debuggerWindow\">要注册的调试器窗口。</param>\n        /// <param name=\"args\">初始化调试器窗口参数。</param>\n        public void RegisterDebuggerWindow(string path, IDebuggerWindow debuggerWindow, params object[] args)\n        {\n            if (string.IsNullOrEmpty(path))\n            {\n                throw new GameFrameworkException(\"Path is invalid.\");\n            }\n\n            if (debuggerWindow == null)\n            {\n                throw new GameFrameworkException(\"Debugger window is invalid.\");\n            }\n\n            m_DebuggerWindowRoot.RegisterDebuggerWindow(path, debuggerWindow);\n            debuggerWindow.Initialize(args);\n        }\n\n        /// <summary>\n        /// 解除注册调试器窗口。\n        /// </summary>\n        /// <param name=\"path\">调试器窗口路径。</param>\n        /// <returns>是否解除注册调试器窗口成功。</returns>\n        public bool UnregisterDebuggerWindow(string path)\n        {\n            return m_DebuggerWindowRoot.UnregisterDebuggerWindow(path);\n        }\n\n        /// <summary>\n        /// 获取调试器窗口。","sourceCodeStart":86,"sourceCodeEnd":122,"githubUrl":"https://github.com/EllanJiang/GameFramework/blob/d0c010b05167c58e92350449d04864a91ca13fd2/GameFramework/Debugger/DebuggerManager.cs#L86-L122","documentation":"DebuggerManager.RegisterDebuggerWindow throws this when the debuggerWindow instance is null. After validating the path, the manager checks the window reference before registering it in the root group and calling Initialize(args). A null window cannot be initialized or rendered.","triggerScenarios":"Passing null instead of an IDebuggerWindow instance; passing a factory result that returned null; conditionally created window instances that ended up null (e.g. #if-compiled-out class).","commonSituations":"Custom debugger windows behind compilation symbols that resolve to null in some build configurations; DI/factory failures returning null; copy-paste forgetting to instantiate the window.","solutions":["Instantiate the window class before registering: new MyDebuggerWindow().","Check the instance for null before calling RegisterDebuggerWindow.","Fix the factory/creation logic that returned null."],"exampleFix":"// before\nIMyWindow win = CreateWindow(); // may be null\ndebugger.RegisterDebuggerWindow(\"Custom/My\", win);\n// after\nvar win = CreateWindow() ?? new MyDebuggerWindow();\ndebugger.RegisterDebuggerWindow(\"Custom/My\", win);","handlingStrategy":"type-guard","validationCode":"if (window == null) window = new MyDebuggerWindow();","typeGuard":"static bool IsValidWindow(IDebuggerWindow w) => w != null;","tryCatchPattern":"try { debugger.RegisterDebuggerWindow(path, window, args); }\ncatch (GameFrameworkException) { Log.Warning(\"Cannot register a null debugger window\"); }","preventionTips":["Instantiate windows explicitly rather than via nullable factories","Null-check factory/conditional (#if) window creation results","Register windows in one well-tested initialization path"],"tags":["debugger","null-reference","csharp","gameframework"],"backgroundTag":"null-argument","analyzedSha":"d0c010b05167c58e92350449d04864a91ca13fd2","analyzedAt":"2026-09-15T13:37:15.352Z","contentChangedAt":"2026-09-15T13:37:15.352Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}