stride3d/stride · error · ArgumentNullException
coreWindow
Error message
coreWindow
What it means
InputSourceUWP's constructor requires a valid UWP CoreWindow to attach input handlers to. If the coreWindow parameter is null, the constructor immediately throws ArgumentNullException via the null-coalescing throw expression. This library fails fast because an input source without a window cannot receive any pointer or keyboard events.
Solutions
- Ensure the CoreWindow is obtained (CoreWindow.GetForCurrentThread()) on the UI thread before constructing InputSourceUWP.
- Guard the construction site with a null check and defer input-source creation until the window is ready.
- Run input source setup on the main/UI thread so the current CoreWindow is resolvable.
Example fix
// before
var source = new InputSourceUWP(someWindowField);
// after
if (someWindowField == null)
throw new InvalidOperationException("InputSourceUWP requires an initialized CoreWindow; create it on the UI thread.");
var source = new InputSourceUWP(CoreWindow.GetForCurrentThread()); Defensive patterns
Strategy: validation
Validate before calling
if (coreWindow == null)
throw new InvalidOperationException("InputSourceUWP requires a CoreWindow; obtain it via CoreWindow.GetForCurrentThread() on the UI thread.");
var source = new InputSourceUWP(coreWindow); Type guard
bool HasCoreWindow(Windows.UI.Core.CoreWindow w) => w != null;
Try / catch
try
{
var source = new InputSourceUWP(coreWindow);
}
catch (ArgumentNullException)
{
// Defer initialization until the UI thread provides a CoreWindow.
} Prevention
- Create the input source on the UI thread only.
- Assert the CoreWindow is resolved before input setup.
- Never pass window fields that may be assigned lazily.
When it happens
Trigger: Calling new InputSourceUWP(null) or passing a CoreWindow field/property that has not yet been initialized when constructing the input source.
Common situations: Setting up Stride input in a UWP app before Window.Current/CoreWindow is available (e.g. in a background thread or before activation completes); refactoring code so a window field is no longer assigned before the input source is created.
Related errors
- Cannot add null instance of VirtualButton
- Cannot set null instance of VirtualButton
- uiControl
- A Gear constraint always needs two rigidbodies to be…
- ActivatedGestures collection was modified but the action…
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/9a9f6b8978f5cea1.
Report an issue: GitHub.
Appendix: source
Thrown at sources/engine/Stride.Input/UWP/InputSourceUWP.cs:47
private readonly CoreWindow coreWindow;
private WindowsAccelerometer windowsAccelerometer;
private WindowsCompass windowsCompass;
private WindowsGyroscope windowsGyroscope;
private WindowsOrientation windowsOrientation;
private AccelerometerSensor accelerometer;
private CompassSensor compass;
private GyroscopeSensor gyroscope;
private OrientationSensor orientation;
private GravitySensor gravity;
private UserAccelerationSensor userAcceleration;
private PointerUWP pointer;
private KeyboardUWP keyboard;
public InputSourceUWP(CoreWindow coreWindow)
{
this.coreWindow = coreWindow ?? throw new ArgumentNullException(nameof(coreWindow));
}
public override void Initialize(InputManager inputManager)
{
var mouseCapabilities = new MouseCapabilities();
if (mouseCapabilities.MousePresent > 0)
{
pointer = new MouseUWP(this, coreWindow);
RegisterDevice(pointer);
}
var keyboardCapabilities = new KeyboardCapabilities();
if (keyboardCapabilities.KeyboardPresent > 0)
{
keyboard = new KeyboardUWP(this, coreWindow);
RegisterDevice(keyboard);
}
View on GitHub (pinned to 96fad776d2)