microsoft/ailab · error · InvalidOperationException

no image to share

Error message

no image to share

What it means

In the share workflow, AppManager must first materialize the current image to a temporary file to attach to an email; this error is the sentinel failure path when no shareable image exists. It fires when the email client could not be opened with the generated file and neither ViewModel.InkedImage nor ViewModel.CapturedImage is set — i.e. the user hit Share without any captured or inked image in the session.

Solutions

  1. Guard the Share action: disable the Share button until an image has been captured or inked
  2. Before sharing, check ViewModel.InkedImage and ViewModel.CapturedImage and show a user-facing message prompting to capture or annotate an image first
  3. If an image exists but the temp file failed, regenerate the snapshot before retrying the email flow
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at Snip-Insights/SnipInsight/AppManager.cs:1661 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/b800fa6a0e6586f5. Report an issue: GitHub.

Appendix: source

Thrown at Snip-Insights/SnipInsight/AppManager.cs:1661

                }

                // Try and open email client with attachment.
                if (!EmailManager.OpenEmailClientWithEmbeddedImage(file, subject, attachmentName, "image/png"))
                {
                    File.Delete(file);
                    bool success;
                    // Do Work
                    if (ViewModel.InkedImage != null)
                    {
                        success = ClipboardManager.Copy(ViewModel.InkedImage);
                    }
                    else if (ViewModel.CapturedImage != null)
                    {
                        success = ClipboardManager.Copy(ViewModel.CapturedImage);
                    }
                    else
                    {
                        throw new InvalidOperationException("no image to share");
                    }

                    if (success)
                    {
                        string mailToImageFormat = "mailto:?subject=" + subject + "&body=Capture copied to clipboard. please paste here";
                        Process.Start(mailToImageFormat);
                    }
                    else
                    {
                        ToastControl toast = new ToastControl(Resources.Message_CopyToClipboardFailed);
                        toast.ShowInMainWindow();
                    }
                }
            }
            catch (Exception ex)
            {
                Diagnostics.ReportException(ex);
            }

View on GitHub (pinned to 89fe2fc620)