Page 1 of 1

ObjectDisposedException ('Frame reference already disposed') after cancelled captures

Posted: Fri Oct 23, 2026 11:32 pm
by EduardoG
Hi Robin,

I’ve recently upgraded to SharpCap 4.2 (v4.2.15192.0 X64 on Win 11 Pro Build 10.0.26200, ASI2600MCPro Driver v3.27) and have been finding the new features very helpful.

However, I’ve run into an issue where SharpCap throws ObjectDisposedException exceptions after certain actions such as a meridian flip (Log_2026-10-08T18_58_49-6504.log), cancelling a sequence (Log_2026-10-08T21_01_56-11424.log), or stopping a "goto image" (Log_2026-10-03T19_25_39-13972.log). I did not experience this problem in version 4.1.

I have uploaded three logs showing the problem. Below is an extract of Log_2026-10-08T18_58_49-6504.log during a meridian flip.

< … Step: Stop running at -0.1 of meridian …>:

Code: Select all

Info   	20:41:28.908170	#33	=='Stop condition monitoring' (New Thread)
Info   	20:41:28.908362	#33	Cancelling single frame capture in void System.Threading.ExecutionContext.RunInternal(...)
<... meridian flip actions and subsequent plate-solve after goto ...>

Code: Select all

Debug  	20:43:33.159711	#2 	Started async Task<FrameCaptureResult> SharpCap.Models.Camera.CaptureSingleFrameStillAsync(...)
Debug  	20:43:33.159859	#2 	Notification (Status=Progress): Exposure in progress for 4.0s
Debug  	20:43:33.173374	#23	Starting ZWO Exposure of 4000ms
Debug  	20:43:37.643754	#23	Finished ZWO Exposure of 4000ms, gotFrame = True
Error  	20:43:37.659307	#2 	Capturing still single frame : Exception of type 'ObjectDisposedException' : Cannot access a disposed object.
Object name: 'Frame reference already disposed'. 
Stack Trace:   at ICapturedFrame SharpCap.Base.FrameReference.get_Frame() in C:/Documents/Source Code/SharpCap/src/SharpCap.Base/FrameReference.cs:line 12
   at Task<FrameToSolve> SharpCap.Models.CurrentCameraFrameToSolveProvider.GetFrameFromCameraAsyncImpl(...)
I tried rerunning the sequence but got the same error:

Code: Select all

Info   	21:00:25.372166	#28	=='Single Frame Thread' (New Thread)
Warning	21:00:25.372295	#28	Trying to grab frame : Exception of type 'ObjectDisposedException' : Cannot access a disposed object.
Object name: 'Frame reference already disposed'. 
Closing and re-opening the camera does not clear the state:

Code: Select all

Info   	21:00:46.486093	#2 	Changing camera from none to ZWO ASI2600MC Pro
Info   	21:00:46.597583	#2 	Capture Event : OpeningDevice
...
info   	21:01:27.802966	#32	=='Single Frame Thread' (New Thread)
Warning	21:01:27.803035	#32	Trying to grab frame : Exception of type 'ObjectDisposedException' : Cannot access a disposed object.
Object name: 'Frame reference already disposed'.
It seems like cancelling a frame capture might be leaving an object (the underlying frame?) in an inconsistent state.

Any ideas that could help me diagnose this problem?

BTW: I tried to set up a sequence to run a script located in C:\Users\eduardo\Astronomy\ntfy.sh, but the Sequence Editor read the \n in the path as a newline. It worked after I renamed the directory to sntfy.sh.

Code: Select all

7:25:44 PM Starting  : Run the python script in C:\Users\eduardo\Astronomy
tfy.sh\send_gen_ntfy_ip.py
7:25:44 PM Error     : 'The script file C:\Users\eduardo\Astronomy
tfy.sh\send_gen_ntfy_ip.py does not exist' while running step Run the python script in C:\Users\eduardo\Astronomy
tfy.sh\send_gen_ntfy_ip.py
7:25:44 PM Info      : 'The script file C:\Users\eduardo\Astronomy
tfy.sh\send_gen_ntfy_ip.py does not exist' while running step Ignore any errors when running these steps
7:25:44 PM End       : Sequence halted due to error.
7:25:44 PM Finished
Thanks
Eduardo

Re: ObjectDisposedException ('Frame reference already disposed') after cancelled captures

Posted: Sat Oct 24, 2026 8:38 am
by Jean-Francois
Hello,

I had two night ago the same error (Frame ... disposed).

Concerning the "\n" ... try to double all the "\" in "\\".

Regards,
Jean-Francois

Re: ObjectDisposedException ('Frame reference already disposed') after cancelled captures

Posted: Sat Oct 24, 2026 1:13 pm
by admin
Hi,

OK, two bugs here that both look real...

The '\n' doesn't survive a save then reload from the sequence editor, so that's definitely my problem. Sadly \\n doesn't fix it , you just get a backslash followed by a newline when loading :( - mind you, that is probably how I will end up fixing this...

The other issue looks intermittent from the logs (damn!) and doesn't show up for me (double damn!). It's probably a timing issue/race condition between getting the frame image data for the purpose of plate solving and something else neatly cleaning it up. That will take some digging. Thanks for posting the logs which help me with where to dig :)

cheers,

Robin