microsoft/ailab · error · InvalidOperationException
no image to copy
Error message
no image to copy
What it means
The Copy command logs the CopyImageButton event and then attempts to put the current image on the clipboard; this error is the sentinel failure when there is no image data to copy. It fires when the acetate layer has no ink (so no InkedImage can be snapshotted) and no CapturedImage exists either — the user invoked Copy before capturing or annotating anything.
Solutions
- Check MainWindow.acetateLayer.HasInk() and ViewModel.CapturedImage before invoking the copy logic and show a friendly message when both are empty
- Disable the Copy button in the ActionRibbon until an image is available
- Ensure PictureConverter.GenerateSnapshot produced a non-null image before calling ClipboardManager.Copy
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at Snip-Insights/SnipInsight/AppManager.cs:1773 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of microsoft/ailab@89fe2fc620 (2026-09-13).
Data as JSON: /api/errors/f61ddb0d99534e08.
Report an issue: GitHub.
Appendix: source
Thrown at Snip-Insights/SnipInsight/AppManager.cs:1773
{
Telemetry.ApplicationLogger.Instance.SubmitButtonClickEvent(Telemetry.EventName.CopyImageButton, Telemetry.ViewName.ActionRibbon);
try
{
// copy to clipboard.
bool success;
// Do Work
if (MainWindow.acetateLayer.HasInk())
{
ViewModel.InkedImage = PictureConverter.GenerateSnapshot(MainWindow.contentImage, MainWindow.acetateLayer.InkCanvas);
success = ClipboardManager.Copy(ViewModel.InkedImage);
}
else if (ViewModel.CapturedImage != null)
{
success = ClipboardManager.Copy(ViewModel.CapturedImage);
}
else
{
throw new InvalidOperationException("no image to copy");
}
ToastControl toast = new ToastControl(success ? Resources.Message_CopiedToClipboard : Resources.Message_CopyToClipboardFailed);
toast.ShowInMainWindow();
}
catch (Exception ex)
{
Diagnostics.ReportException(ex);
}
finally
{
// Trigger
ViewModel.StateMachine.Fire(SnipInsightTrigger.CopyingWithImageCompleted);
}
}
#endregion
#region Events
void OnLoaded(object sender, RoutedEventArgs e)View on GitHub (pinned to 89fe2fc620)