[GH-ISSUE #1243] [Bug] Unhandled Exception: "Cannot set visibility or call Show, ShowDialog ... after a Window has closed" #3312

Open
opened 2026-03-01 19:09:55 +03:00 by kerem · 0 comments
Owner

Originally created by @Emxm3 on GitHub (Oct 10, 2023).
Original GitHub issue: https://github.com/NickeManarin/ScreenToGif/issues/1243

Originally assigned to: @NickeManarin on GitHub.

Describe the bug
Stopping a recording when the recorders window is not shown throws an unhandled exception

To Reproduce
Steps to reproduce the behavior:

  1. Go to "Options" > "Recorder" > [ X ] Enable selection panning
  2. Set a shortcut key to enable panning while recording.
  3. Move the mouse in a way that moves the window's location to a new location (this makes the window disappear until the mouse stops).
  4. As the window disappears, quickly press F8 (stops recording)
  5. An error will be thrown. recording is fine and no data is lost, but is a bit of an annoyance

Expected behavior
Recording should stop and application flow should continue as normal with no unexpected pop-ups

Screenshots
image

Desktop (please complete the following information):

  • OS: Windows 11
  • Version 2.37 - 2.39

Additional context

System.InvalidOperationException: Cannot set Visibility or call Show, ShowDialog, or WindowInteropHelper.EnsureHandle after a Window has closed.
   at System.Windows.Window.VerifyCanShow()
   at System.Windows.Window.Show()
   at ScreenToGif.Windows.Other.RegionSelection.Select(Nullable`1 mode, Rect region, Monitor monitor) in C:\Users\nicke\source\repos\ScreenToGif\ScreenToGif\Windows\Other\RegionSelection.xaml.cs:line 197
   at ScreenToGif.Windows.NewRecorder.DisplaySelection(Nullable`1 mode, Monitor display) in C:\Users\nicke\source\repos\ScreenToGif\ScreenToGif\Windows\NewRecorder.xaml.cs:line 1483
   at ScreenToGif.Windows.NewRecorder.ShowBorderTimer_Tick(Object sender, EventArgs e) in C:\Users\nicke\source\repos\ScreenToGif\ScreenToGif\Windows\NewRecorder.xaml.cs:line 717
   at System.Windows.Forms.Timer.TimerNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, WM msg, IntPtr wparam, IntPtr lparam)
Originally created by @Emxm3 on GitHub (Oct 10, 2023). Original GitHub issue: https://github.com/NickeManarin/ScreenToGif/issues/1243 Originally assigned to: @NickeManarin on GitHub. **Describe the bug** Stopping a recording when the recorders window is not shown throws an unhandled exception **To Reproduce** Steps to reproduce the behavior: 1. Go to "Options" > "Recorder" > [ X ] Enable selection panning 2. Set a shortcut key to enable panning while recording. 3. Move the mouse in a way that moves the window's location to a new location (this makes the window disappear until the mouse stops). 4. As the window disappears, quickly press F8 (stops recording) 5. An error will be thrown. recording is fine and no data is lost, but is a bit of an annoyance **Expected behavior** Recording should stop and application flow should continue as normal with no unexpected pop-ups **Screenshots** ![image](https://github.com/NickeManarin/ScreenToGif/assets/1776215/e5daa54b-d582-4621-b265-4023e5d152a1) **Desktop (please complete the following information):** - OS: Windows 11 - Version 2.37 - 2.39 **Additional context** ``` System.InvalidOperationException: Cannot set Visibility or call Show, ShowDialog, or WindowInteropHelper.EnsureHandle after a Window has closed. at System.Windows.Window.VerifyCanShow() at System.Windows.Window.Show() at ScreenToGif.Windows.Other.RegionSelection.Select(Nullable`1 mode, Rect region, Monitor monitor) in C:\Users\nicke\source\repos\ScreenToGif\ScreenToGif\Windows\Other\RegionSelection.xaml.cs:line 197 at ScreenToGif.Windows.NewRecorder.DisplaySelection(Nullable`1 mode, Monitor display) in C:\Users\nicke\source\repos\ScreenToGif\ScreenToGif\Windows\NewRecorder.xaml.cs:line 1483 at ScreenToGif.Windows.NewRecorder.ShowBorderTimer_Tick(Object sender, EventArgs e) in C:\Users\nicke\source\repos\ScreenToGif\ScreenToGif\Windows\NewRecorder.xaml.cs:line 717 at System.Windows.Forms.Timer.TimerNativeWindow.WndProc(Message& m) at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, WM msg, IntPtr wparam, IntPtr lparam) ```
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/ScreenToGif#3312
No description provided.