SubtitleEdit/subtitleedit · error · PlatformNotSupportedException
Clipboard image copy not supported on this platform
Error message
Clipboard image copy not supported on this platform
What it means
Thrown by ClipboardHelper.CopyImageToClipboard when the current OS is none of Windows, Linux, or macOS — i.e. an unsupported platform for the image-copy path. It is the final else branch after the OperatingSystem.Is* checks, so reaching it means the runtime reported a platform with no clipboard-image implementation wired up.
Source
Thrown at src/ui/Logic/ClipboardHelper.cs:168
}
public static async Task CopyImageToClipboard(Bitmap bitmap)
{
if (OperatingSystem.IsWindows())
{
await CopyImageToClipboardWindows(bitmap);
}
else if (OperatingSystem.IsLinux())
{
await CopyImageToClipboardLinux(bitmap);
}
else if (OperatingSystem.IsMacOS())
{
await CopyImageToClipboardMacOS(bitmap);
}
else
{
throw new PlatformNotSupportedException("Clipboard image copy not supported on this platform");
}
}
private static async Task CopyImageToClipboardWindows(Bitmap bitmap)
{
await Task.Run(() =>
{
IntPtr hGlobal = IntPtr.Zero;
try
{
var width = bitmap.PixelSize.Width;
var height = bitmap.PixelSize.Height;
// Save bitmap to memory stream and read pixel data
using var memoryStream = new MemoryStream();
bitmap.Save(memoryStream, PngBitmapEncoderOptions.Default);
memoryStream.Position = 0;View on GitHub (pinned to 17a9f07487)
Solutions
- Guard the call site with OperatingSystem.IsWindows/Linux/MacOS before invoking image copy.
- On an unsupported platform, fall back to text-only clipboard or skip the operation gracefully.
- If you need a new platform, implement its own CopyImageToClipboard<Platform> branch and add it to the dispatch.
Example fix
// before
await ClipboardHelper.CopyImageToClipboard(bitmap);
// after - gate by platform and degrade gracefully
if (OperatingSystem.IsWindows() || OperatingSystem.IsLinux() || OperatingSystem.IsMacOS())
await ClipboardHelper.CopyImageToClipboard(bitmap);
else
await ClipboardHelper.SetTextAsync(window, "Image copy is not supported on this platform."); Defensive patterns
Strategy: validation
Validate before calling
if (!(OperatingSystem.IsWindows() || OperatingSystem.IsLinux() || OperatingSystem.IsMacOS()))
{
// degrade gracefully: copy text or skip
return;
} Try / catch
try { await ClipboardHelper.CopyImageToClipboard(bitmap); }
catch (PlatformNotSupportedException ex) { SeLogger.Warning(ex.Message); /* skip image copy */ } Prevention
- Gate image copy by platform at the call site.
- Provide a text-only fallback on unsupported platforms.
- Add a dedicated branch when adding a new platform target.
When it happens
Trigger: Running the image-copy code path on FreeBSD, a BSD-derived system, or any platform where OperatingSystem.IsWindows/IsLinux/IsMacOS all return false.
Common situations: Community builds on unsupported OSes; a container/sandbox whose runtime platform detection returns an unrecognized value; future platform targets not yet implemented.
Related errors
- Failed to decode bitmap
- Failed to allocate global memory
- Failed to set clipboard data
- Unsupported OS platform.
- Process.Start() is not supported on this platform.
AI-assisted analysis of SubtitleEdit/subtitleedit@17a9f07487 (2026-08-13).
Data as JSON: /api/errors/658236be6767806a.
Report an issue: GitHub.