NickeManarin/ScreenToGif · warning · 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
Identical root cause to error 41 but thrown inside DownloadDialog.CenterOnScreen(). MonitorHelper.AllMonitorsGranular() returns an empty list, so the FirstOrDefault chain (point-containing, primary, any) resolves to null and the generic Exception fires. This dialog centers itself on the closest monitor before showing, and cannot do so without an enumerated screen.
Source
Thrown at ScreenToGif/Windows/Other/DownloadDialog.xaml.cs:267
}
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
Global.UpdateAvailable.TaskCompletionSource = null;
}
private void CenterOnScreen()
{
//Since the list of monitors could have been changed, it needs to be queried again.
var monitors = MonitorHelper.AllMonitorsGranular();
//Detect closest screen to the point (previously selected top/left point or current mouse coordinate).
var point = new Point((int)Left, (int)Top);
var closest = monitors.FirstOrDefault(x => x.Bounds.Contains(point)) ?? monitors.FirstOrDefault(x => x.IsPrimary) ?? monitors.FirstOrDefault();
if (closest == null)
throw new Exception("It was not possible to get a list of known screens.");
//Move the window to the correct location.
Left = closest.WorkingArea.Left + closest.WorkingArea.Width / 2d - ActualWidth / 2d;
Top = closest.WorkingArea.Top + closest.WorkingArea.Height / 2d - ActualHeight / 2d;
}
}View on GitHub (pinned to a4d0a67c21)
Solutions
- Ensure a display is connected and active before triggering the download dialog.
- Reconnect displays and reopen the dialog so CenterOnScreen re-enumerates.
- Catch the exception in CenterOnScreen and skip centering (let WPF place the window) instead of crashing the download flow.
- Guard: if the monitor list is empty, fall back to SystemParameters.WorkArea for centering.
Example fix
// before
var monitors = MonitorHelper.AllMonitorsGranular();
var point = new Point((int)Left, (int)Top);
var closest = monitors.FirstOrDefault(x => x.Bounds.Contains(point)) ?? monitors.FirstOrDefault(x => x.IsPrimary) ?? monitors.FirstOrDefault();
if (closest == null)
throw new Exception("It was not possible to get a list of known screens.");
Left = closest.WorkingArea.Left + closest.WorkingArea.Width / 2d - ActualWidth / 2d;
Top = closest.WorkingArea.Top + closest.WorkingArea.Height / 2d - ActualHeight / 2d;
// after: fall back to primary working area, never throw on layout
var monitors = MonitorHelper.AllMonitorsGranular();
var closest = monitors.FirstOrDefault(x => x.Bounds.Contains(new Point((int)Left, (int)Top))
?? monitors.FirstOrDefault(x => x.IsPrimary)
?? monitors.FirstOrDefault();
var area = closest?.WorkingArea ?? SystemParameters.WorkArea;
Left = area.Left + area.Width / 2d - ActualWidth / 2d;
Top = area.Top + area.Height / 2d - ActualHeight / 2d; Defensive patterns
Strategy: fallback
Validate before calling
// Validate enumeration before centering the dialog.
var monitors = MonitorHelper.AllMonitorsGranular();
if (monitors.Count == 0)
{
// Fall back to the WPF primary working area; do not throw.
var wa = SystemParameters.WorkArea;
Left = wa.Left + wa.Width / 2d - ActualWidth / 2d;
Top = wa.Top + wa.Height / 2d - ActualHeight / 2d;
return;
} Type guard
static Rect ResolveCenterArea(List<Monitor> monitors, Point point)
{
var closest = monitors.FirstOrDefault(x => x.Bounds.Contains(point))
?? monitors.FirstOrDefault(x => x.IsPrimary)
?? monitors.FirstOrDefault();
return closest?.WorkingArea ?? SystemParameters.WorkArea;
} Try / catch
try
{
CenterOnScreen();
}
catch (Exception e) when (e.Message.Contains("list of known screens"))
{
// Center on the WPF primary work area; the download must still proceed.
LogWriter.Log(e, "Monitor enumeration failed in CenterOnScreen; using SystemParameters.WorkArea.");
var wa = SystemParameters.WorkArea;
Left = wa.Left + wa.Width / 2d - ActualWidth / 2d;
Top = wa.Top + wa.Height / 2d - ActualHeight / 2d;
} Prevention
- Layout/centering code should never throw — always degrade to SystemParameters.
- Retry AllMonitorsGranular() once before giving up, since display changes are transient.
- Defer CenterOnScreen until after the DisplaySettingsChanged event settles.
- Treat monitor enumeration as best-effort in dialog windows, not a hard prerequisite.
When it happens
Trigger: CenterOnScreen() is called when the DownloadDialog is being positioned/shown. AllMonitorsGranular() returns empty because User32.EnumDisplayMonitors enumerated no displays — the same native-empty condition as error 41 but triggered from a different window's layout path.
Common situations: Monitors disconnected/locked while a download was triggered; the dialog opens during a display-settings-change transition; running from a non-interactive or RDP-disconnected session; display driver crashed leaving no GDI desktop during the dialog open.
Related errors
- 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
- It was not possible to move the current selected region to t
AI-assisted analysis of NickeManarin/ScreenToGif@a4d0a67c21 (2026-08-13).
Data as JSON: /api/errors/cdbe8912be6f24cb.
Report an issue: GitHub.