stride3d/stride · error · ArgumentNullException
uiControl
Error message
uiControl
What it means
InputSourceWindowsRawInput's constructor requires a WinForms Control to which raw input messages (WM_INPUT) are hooked. Passing a null uiControl throws ArgumentNullException immediately via the null-coalescing throw. Raw input cannot be registered without a window handle to receive messages.
Solutions
- Create and show the main Form first, then construct InputSourceWindowsRawInput with it.
- Verify the Control variable is assigned before constructing the input source.
- Choose an input source appropriate for headless scenarios (or a non-RawInput backend) when no window exists.
Example fix
// before
var source = new InputSourceWindowsRawInput(mainForm);
// after
if (mainForm == null || mainForm.IsDisposed)
throw new InvalidOperationException("Raw input requires a live WinForms control.");
var source = new InputSourceWindowsRawInput(mainForm); Defensive patterns
Strategy: validation
Validate before calling
if (uiControl == null || uiControl.IsDisposed)
throw new InvalidOperationException("InputSourceWindowsRawInput requires a live WinForms control.");
var source = new InputSourceWindowsRawInput(uiControl); Type guard
bool HasLiveControl(Control c) => c != null && !c.IsDisposed && c.IsHandleCreated;
Try / catch
try
{
var source = new InputSourceWindowsRawInput(uiControl);
}
catch (ArgumentNullException)
{
// Wait for form creation, then retry input initialization.
} Prevention
- Initialize input sources after the main form is constructed.
- Verify the control handle exists before raw-input registration.
- Avoid constructing window-backed input sources in headless tests.
When it happens
Trigger: Calling new InputSourceWindowsRawInput(null) or passing a Control field that is not yet created.
Common situations: Headless/server-side instantiation where no WinForms UI exists; constructing the input source before the main form is created; refactoring where the form reference is assigned later.
Related errors
- uiControl
- Failed to register a mouse device for raw input
- Failed to unregister a mouse device for raw input
- form
- renderCallback
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/030a414791b27f96.
Report an issue: GitHub.
Appendix: source
Thrown at sources/engine/Stride.Input/Windows/InputSourceWindowsRawInput.cs:23
using System;
using System.Windows.Forms;
using SharpDX.Multimedia;
using SharpDX.RawInput;
using Stride.Games;
namespace Stride.Input
{
/// <summary>
/// Provides support for raw keyboard input on windows
/// </summary>
internal class InputSourceWindowsRawInput : InputSourceBase
{
private readonly Control uiControl;
private KeyboardWindowsRawInput keyboard;
public InputSourceWindowsRawInput(Control uiControl)
{
this.uiControl = uiControl ?? throw new ArgumentNullException(nameof(uiControl));
}
public override void Initialize(InputManager inputManager)
{
keyboard = new KeyboardWindowsRawInput(this);
RegisterDevice(keyboard);
BindRawInputKeyboard(uiControl);
}
public override void Update()
{
}
public override void Dispose()
{
// Unregisters devices
base.Dispose();
View on GitHub (pinned to 96fad776d2)