babalae/better-genshin-impact · error · InvalidOperationException
当前没有可用的桌面分身,请先启动桌面分身。
Error message
当前没有可用的桌面分身,请先启动桌面分身。
What it means
Thrown by ChildSessionService.GetRequiredChildSessionId when ChildSessionNativeMethods.TryGetChildSessionId() returns null — no Windows Child Session (desktop clone) is currently active, so there is no target session ID to launch a process into.
Source
Thrown at BetterGenshinImpact/Service/ChildSession/ChildSessionService.cs:527
RefreshState(isAutomatic
? "桌面分身已加载,正在自动以管理员权限启动 BetterGI"
: "正在以管理员权限启动 BetterGI");
await ChildSessionProcessLauncher.LaunchBetterGiAsync(childSessionId);
RefreshState(
$"已在桌面分身(会话 {childSessionId})中以管理员权限启动 BetterGI");
}
finally
{
_launchSemaphore.Release();
}
}
private uint GetRequiredChildSessionId()
{
var childSessionId = ChildSessionNativeMethods.TryGetChildSessionId();
if (childSessionId is null)
{
throw new InvalidOperationException("当前没有可用的桌面分身,请先启动桌面分身。");
}
return childSessionId.Value;
}
private void EnsureChildSessionsEnabled()
{
if (!ChildSessionNativeMethods.IsChildSessionsEnabled())
{
ChildSessionNativeMethods.EnableChildSessions();
}
}
private void OnDesktopWindowVisibilityChanged(object sender, DependencyPropertyChangedEventArgs e)
{
RefreshState();
}
View on GitHub (pinned to a7cb36712d)
Solutions
- Call StartAsync() first and wait for the Child Session to reach ConnectedState == 1 (logged in).
- Ensure Child Sessions are enabled on the OS (EnsureChildSessionsEnabled runs automatically during StartAsync).
- If the session was logged off, restart it before launching programs into it.
Defensive patterns
Strategy: validation
Validate before calling
// Ensure a Child Session is active before launching into it.
if (ChildSessionNativeMethods.TryGetChildSessionId() is null)
{
throw new InvalidOperationException("当前没有可用的桌面分身,请先启动桌面分身。");
} Try / catch
try
{
await childSessionService.LaunchExecutableAsync(exePath);
}
catch (InvalidOperationException ex) when (ex.Message.Contains("桌面分身"))
{
logger.LogError(ex, "No active Child Session; start one first");
} Prevention
- Call StartAsync() and wait for ConnectedState == 1 before exposing launch-into-session actions.
- Disable the launch button in the UI until a Child Session ID is present.
- Handle the case where the session was logged off out-of-band by re-checking before each launch.
When it happens
Trigger: Calling LaunchBetterGiAsync() or LaunchExecutableAsync() before the RDP Child Session connection has been established and logged in. The Child Session only gets a session ID after Windows assigns one during the RDP logon sequence.
Common situations: User clicks "launch program into Child Session" before clicking "start desktop clone"; the Child Session was logged off or terminated out-of-band; the RDP connection is still in the connecting state (ConnectedState != 1).
Related errors
- 同一个 BvFlow 不能并发执行
- BvFlow 第 {i + 1} 步执行失败:{step.Description}
- BvFlow 已经开始执行,不能再添加步骤
- {paramName} 必须大于 0
- 动作 {snapshot.Description} 执行 {attempts} 次后,等待 {snapshot.Targ
AI-assisted analysis of babalae/better-genshin-impact@a7cb36712d (2026-08-13).
Data as JSON: /api/errors/d545c9336232520b.
Report an issue: GitHub.