Page 1 of 3
PictureBox Crashes
Posted: Mon Jul 04, 2016 9:03 pm
by sgraves
We have been getting crashes which say "InvalidOperationException - object is currently in use elsewhere" for mainly the Placement_PictureBox and it goes to a box with red diagonal lines. We must restart the program to get the image back.
At line 6077 in MainForm.cs we have the following
Code: Select all
private void Placement_pictureBox_MouseMove(object sender, MouseEventArgs e)
{
General_pictureBox_MouseMove(Tapes_pictureBox, e.X, e.Y);
}
Is this a bug? Or is the Tapes_pictureBox object supposed to be passed along in this function?
Re: PictureBox Crashes
Posted: Tue Jul 05, 2016 8:45 am
by JuKu
> Or is the Tapes_pictureBox object supposed to be passed along in this function?
A reference to the box, yes. This is bad coding practice on my side. It would be much clearer actually writing ref, although in C#, anything other than ValueTypes (like objects) are passed by reference anyway.
I've been looking for the cause of that error (it is hard to debug something that I can't reproduce). It is because the UI and the video section both need access to the picturebox. Even though I have locks and sync code in place, there is a simultaneous access attempt at some point. Either I'm still missing a lock or I don't fully understand the UI internals. If you get any more specific error messages, I would much appreciate getting the info.
Re: PictureBox Crashes
Posted: Tue Jul 05, 2016 2:25 pm
by sgraves
So on a mouse move event in the Placement_pictureBox one should be passing the Tapes_pictureBox object to the General_pictureBox_MouseMove function? Why not pass the Placement_pictureBox object? I am not familiar with these Windows objects, so I don't really understand what is happening. It just seems wrong. The Tapes_pictureBox is on a different tab. Are they precisely aligned with each other? Do they both give the same result for the underlying mouse move code?
Re: PictureBox Crashes
Posted: Tue Jul 05, 2016 2:31 pm
by sgraves
BTW In my opinion it is not bad coding practice to write the reference that way. Any decent programmer should know that is a reference.
Re: PictureBox Crashes
Posted: Tue Jul 05, 2016 8:35 pm
by Danal
Update if it helps debug:
The release posted July 5th seems to be MUCH more stable.
Every single time I've gotten a Red X and/or dialog box indicating a crash, it has been when I am loading a "Run Job" file.
Again, it is about 10 times more stable than it was... and this is making setup much easier... keep up the good work!
Danal
Re: PictureBox Crashes
Posted: Tue Jul 05, 2016 8:46 pm
by Danal
Hmmm... just got the RedX after a placement. Hmmm...
Re: PictureBox Crashes
Posted: Wed Jul 06, 2016 10:40 am
by JuKu
> Every single time I've gotten a Red X and/or dialog box indicating a crash, it has been when I am loading a "Run Job" file.
This helps, probably. Anything indicating what you did to get the X is a clue.
Re: PictureBox Crashes
Posted: Wed Jul 06, 2016 4:27 pm
by Danal
JuKu wrote:> Every single time I've gotten a Red X and/or dialog box indicating a crash, it has been when I am loading a "Run Job" file.
This helps, probably. Anything indicating what you did to get the X is a clue.
After having intensely used the software for setup and calibration yesterday, it is crashing at several points. Once after a place, once or twice at other times that I don't remember, but the overwhelmingly most common time is when loading a cad CSV or a job file. Saving a file doesn't seem to trigger it... maybe once... but not often. Loading is by far the most common point.
Re: PictureBox Crashes
Posted: Wed Jul 06, 2016 8:55 pm
by sgraves
Juha,
Below is a dump of the exception report for the crash. As you can see the paint operation is having the issue.
Steve
See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.
************** Exception Text **************
System.InvalidOperationException: Object is currently in use elsewhere.
at System.Drawing.Image.get_Width()
at System.Windows.Forms.PictureBox.ImageRectangleFromSizeMode(PictureBoxSizeMode mode)
at System.Windows.Forms.PictureBox.OnPaint(PaintEventArgs pe)
at System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer)
at System.Windows.Forms.Control.WmPaint(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
************** Loaded Assemblies **************
mscorlib
Assembly Version: 4.0.0.0
Win32 Version: 4.6.1080.0 built by: NETFXREL3STAGE
CodeBase: file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/mscorlib.dll
----------------------------------------
LitePlacer
Assembly Version: 1.0.6031.27950
Win32 Version: 1.0.0.0
CodeBase: file:///C:/Users/test/Desktop/Debug/LP_w_data/LitePlacer.exe
----------------------------------------
System.Core
Assembly Version: 4.0.0.0
Win32 Version: 4.6.1038.0 built by: NETFXREL2
CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Core/v4.0_4.0.0.0__b77a5c561934e089/System.Core.dll
----------------------------------------
System
Assembly Version: 4.0.0.0
Win32 Version: 4.6.1081.0 built by: NETFXREL3STAGE
CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
System.Windows.Forms
Assembly Version: 4.0.0.0
Win32 Version: 4.6.1038.0 built by: NETFXREL2
CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms/v4.0_4.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
System.Drawing
Assembly Version: 4.0.0.0
Win32 Version: 4.6.1078.0 built by: NETFXREL3STAGE
CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Drawing/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
Accessibility
Assembly Version: 4.0.0.0
Win32 Version: 4.6.1038.0 built by: NETFXREL2
CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/Accessibility/v4.0_4.0.0.0__b03f5f7f11d50a3a/Accessibility.dll
----------------------------------------
System.Configuration
Assembly Version: 4.0.0.0
Win32 Version: 4.6.1038.0 built by: NETFXREL2
CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Configuration/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
----------------------------------------
System.Xml
Assembly Version: 4.0.0.0
Win32 Version: 4.6.1064.2 built by: NETFXREL3STAGE
CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Xml/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.dll
----------------------------------------
AForge.Video.DirectShow
Assembly Version: 2.2.5.0
Win32 Version: 2.2.5.0
CodeBase: file:///C:/Users/test/Desktop/Debug/LP_w_data/AForge.Video.DirectShow.DLL
----------------------------------------
AForge.Video
Assembly Version: 2.2.5.0
Win32 Version: 2.2.5.0
CodeBase: file:///C:/Users/test/Desktop/Debug/LP_w_data/AForge.Video.DLL
----------------------------------------
AForge.Imaging
Assembly Version: 2.2.5.0
Win32 Version: 2.2.5.0
CodeBase: file:///C:/Users/test/Desktop/Debug/LP_w_data/AForge.Imaging.DLL
----------------------------------------
AForge
Assembly Version: 2.2.5.0
Win32 Version: 2.2.5.0
CodeBase: file:///C:/Users/test/Desktop/Debug/LP_w_data/AForge.DLL
----------------------------------------
System.Web.Extensions
Assembly Version: 4.0.0.0
Win32 Version: 4.6.1073.0
CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Web.Extensions/v4.0_4.0.0.0__31bf3856ad364e35/System.Web.Extensions.dll
----------------------------------------
System.Web
Assembly Version: 4.0.0.0
Win32 Version: 4.6.1073.0 built by: NETFXREL3STAGE
CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_32/System.Web/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Web.dll
----------------------------------------
AForge.Math
Assembly Version: 2.2.5.0
Win32 Version: 2.2.5.0
CodeBase: file:///C:/Users/test/Desktop/Debug/LP_w_data/AForge.Math.DLL
----------------------------------------
************** JIT Debugging **************
To enable just-in-time (JIT) debugging, the .config file for this
application or computer (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.
For example:
<configuration>
<system.windows.forms jitDebugging="true" />
</configuration>
When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the computer
rather than be handled by this dialog box.
Re: PictureBox Crashes
Posted: Wed Jul 06, 2016 9:32 pm
by sgraves
Juha,
This URL has some discussion about the invalid operation with paint.
http://stackoverflow.com/questions/1060 ... -red-cross
Perhaps the camera functions like DrawCrossFunct need to be made thread safe?
Steve
This post has been made obsolete by later discoveries. My following post will explain.