stride3d/stride · error · ArgumentException
GameWindow should have either a SwapChainPanel or a…
Error message
GameWindow should have either a SwapChainPanel or a CoreWindow
What it means
GameWindowUWP.ClientBounds requires either a SwapChainPanel or a CoreWindow to measure the window rectangle; when neither is present it throws an ArgumentException naming the missing components. On UWP the render target is hosted by one of these two XAML/Core objects, so a GameWindow without either has no defined client bounds.
Solutions
- Ensure the SwapChainPanel is assigned to the GameWindow before reading ClientBounds (wait for the XAML panel to load).
- Defer bounds queries until after CoreWindow activation (WindowActivated/Loaded callbacks) rather than during construction.
- Fix the hosting code so exactly one of SwapChainPanel/CoreWindow is provided when creating GameWindowUWP.
Example fix
// before
var bounds = gameWindow.ClientBounds; // panel not yet assigned
// after
swapChainPanel.Loaded += (s, e) =>
{
gameWindow.SwapChainPanel = swapChainPanel;
var bounds = gameWindow.ClientBounds;
}; Defensive patterns
Strategy: validation
Validate before calling
bool CanReadBounds(GameWindowUWP w) => w.SwapChainPanel != null || w.CoreWindow != null; var bounds = CanReadBounds(gameWindow) ? gameWindow.ClientBounds : Rect.Empty;
Type guard
bool HasHostSurface(GameWindowUWP w) => w.SwapChainPanel != null || w.CoreWindow != null;
Try / catch
try { var b = gameWindow.ClientBounds; }
catch (ArgumentException ex) when (ex.Message.Contains("SwapChainPanel"))
{
// wait for panel binding / CoreWindow activation, then retry
} Prevention
- Bind the XAML SwapChainPanel to the GameWindow before any layout/bounds logic runs.
- Query bounds only after CoreWindow activation or panel Loaded events.
- In custom UWP hosts, guarantee exactly one host surface is provided.
When it happens
Trigger: Accessing ClientBounds on a GameWindowUWP whose SwapChainPanel and CoreWindow are both null — e.g. the window was constructed but not yet bound to the XAML SwapChainPanel or activated CoreWindow, or queried during/after app suspension.
Common situations: Reading ClientBounds too early during UWP startup before panel binding, custom UWP hosting that never sets SwapChainPanel, or accessing bounds after CoreWindow activation was lost.
Understand the failure class
Background: "not installed", "pip install", "required for": how missing-dependency errors surface across open-source libraries — this error's family across 34 libraries.
Related errors
- The path [ ] contains access to a member of a null object.
- Unable to retrieve the value of this member path on this…
- url cannot be null or empty.
- ArgumentNullException
- Array is null
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/ecdb425d256eb3b2.
Report an issue: GitHub.
Appendix: source
Thrown at sources/engine/Stride.Games/WindowsStore/GameWindowUWP.cs:99
public override Rectangle ClientBounds
{
get
{
if (swapChainPanel != null)
{
return new Rectangle(0, 0,
(int)(swapChainPanel.ActualWidth * swapChainPanel.CompositionScaleX + 0.5f),
(int)(swapChainPanel.ActualHeight * swapChainPanel.CompositionScaleY + 0.5f));
}
if (coreWindow != null)
{
return new Rectangle((int)(coreWindow.Bounds.X), (int)(coreWindow.Bounds.Y), (int)(coreWindow.Bounds.Width), (int)(coreWindow.Bounds.Height));
}
throw new ArgumentException($"{nameof(GameWindow)} should have either a {nameof(SwapChainPanel)} or a {nameof(CoreWindow)}");
}
}
public override DisplayOrientation CurrentOrientation => DisplayOrientation.Default;
public override bool IsMinimized => false;
public override bool Focused => focused;
private bool isMouseVisible;
private CoreCursor cursor;
public override bool IsMouseVisible
{
get
{
return isMouseVisible;
}View on GitHub (pinned to 96fad776d2)