NickeManarin/ScreenToGif · error · Exception
It was not possible to get a list of known screens.
Error message
It was not possible to get a list of known screens.
What it means
NewRecorder centers the recorder panel when the region is empty by picking a screen from _viewModel.Monitors (the one under the cursor, else the primary, else any). If Monitors is empty the whole chain returns null and it throws — there is literally no enumerated display to center on.
Source
Thrown at ScreenToGif/Windows/NewRecorder.xaml.cs:898
}
#endregion
}
//Change the scale of the sizing controls.
WidthIntegerBox.Scale = UserSettings.All.SelectedRegionScale;
HeightIntegerBox.Scale = UserSettings.All.SelectedRegionScale;
#region Adjust the position of the main controls
if (_viewModel.Region.IsEmpty)
{
#region Center on screen
var screen = _viewModel.Monitors.FirstOrDefault(x => x.Bounds.Contains(CursorHelper.GetMousePosition(1, Left, Top))) ?? _viewModel.Monitors.FirstOrDefault(x => x.IsPrimary) ?? _viewModel.Monitors.FirstOrDefault();
if (screen == null)
throw new Exception("It was not possible to get a list of known screens.");
MovePanelTo(screen, screen.WorkingArea.Left + screen.WorkingArea.Width / 2 - RecorderWindow.ActualWidth / 2, screen.WorkingArea.Top + screen.WorkingArea.Height / 2 - RecorderWindow.ActualHeight / 2);
#endregion
}
else
{
MoveCommandPanel();
DisplaySelection((ModeType) UserSettings.All.RecorderModeIndex);
}
#endregion
}
private void ForceUpdate()
{
InvalidateMeasure();
InvalidateArrange();View on GitHub (pinned to a4d0a67c21)
Solutions
- Re-enumerate monitors before throwing — call the monitor detection code and rebuild _viewModel.Monitors.
- Ensure at least one display is connected and powered on before opening the recorder.
- If running over RDP/headless, attach a physical or virtual display.
- Fall back to SystemParameters.PrimaryScreen / SystemInformation.VirtualScreen when Monitors is empty.
Example fix
// before
var screen = _viewModel.Monitors.FirstOrDefault(x => x.Bounds.Contains(CursorHelper.GetMousePosition(1, Left, Top))) ?? _viewModel.Monitors.FirstOrDefault(x => x.IsPrimary) ?? _viewModel.Monitors.FirstOrDefault();
if (screen == null)
throw new Exception("It was not possible to get a list of known screens.");
// after
var screen = _viewModel.Monitors.FirstOrDefault(x => x.Bounds.Contains(CursorHelper.GetMousePosition(1, Left, Top))) ?? _viewModel.Monitors.FirstOrDefault(x => x.IsPrimary) ?? _viewModel.Monitors.FirstOrDefault();
if (screen == null)
throw new Exception("It was not possible to get a list of known screens. No display detected — connect a monitor and reopen the recorder."); Defensive patterns
Strategy: validation
Validate before calling
if (_viewModel.Monitors == null || _viewModel.Monitors.Count == 0)
{
await MonitorEnumerator.EnumerateAsync(); // re-populate _viewModel.Monitors
if (_viewModel.Monitors.Count == 0) /* warn user: no display detected */
} Type guard
bool HasAnyMonitor => _viewModel.Monitors?.Any() == true;
Try / catch
try { /* center panel on screen */ }
catch (Exception ex) when (ex.Message.Contains("known screens"))
{ /* fall back to SystemParameters.PrimaryScreen or warn the user */ } Prevention
- Re-enumerate monitors on SystemEvents.DisplaySettingsChanged.
- Ensure at least one display is connected before opening the recorder.
- Provide a non-throwing fallback rectangle when Monitors is empty.
When it happens
Trigger: _viewModel.Region.IsEmpty AND _viewModel.Monitors is empty, so the FirstOrDefault(x => Bounds.Contains(...)) ?? FirstOrDefault(IsPrimary) ?? FirstOrDefault() chain yields null.
Common situations: Monitor enumeration returned no displays at recorder startup; all displays disconnected after launch; WMI/DXGI enumeration failed silently; headless session; service/context where no user desktop displays exist.
Related errors
- It was not possible to move the current selected region to t
- It was not possible to get a list of known screens.
- It was not possible to get a list of known screens.
- Could not find a proper output device for the area of L: {Le
- Impossible to capture the manual screenshot.
AI-assisted analysis of NickeManarin/ScreenToGif@a4d0a67c21 (2026-08-13).
Data as JSON: /api/errors/f51d3f6e95fb4052.
Report an issue: GitHub.