PictureBox Crashes

sgraves
Posts: 30
Joined: Mon Jul 04, 2016 2:48 am
Location: Tampa, FL USA

PictureBox Crashes

Post 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?
JuKu
Site Admin
Posts: 1110
Joined: Thu Feb 14, 2013 3:06 pm
Location: Tampere, Finland
Contact:

Re: PictureBox Crashes

Post 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.
sgraves
Posts: 30
Joined: Mon Jul 04, 2016 2:48 am
Location: Tampa, FL USA

Re: PictureBox Crashes

Post 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?
sgraves
Posts: 30
Joined: Mon Jul 04, 2016 2:48 am
Location: Tampa, FL USA

Re: PictureBox Crashes

Post 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.
Danal
Posts: 43
Joined: Fri May 29, 2015 11:07 am
Location: Fairview, TX
Contact:

Re: PictureBox Crashes

Post 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
Danal
Posts: 43
Joined: Fri May 29, 2015 11:07 am
Location: Fairview, TX
Contact:

Re: PictureBox Crashes

Post by Danal »

Hmmm... just got the RedX after a placement. Hmmm...
JuKu
Site Admin
Posts: 1110
Joined: Thu Feb 14, 2013 3:06 pm
Location: Tampere, Finland
Contact:

Re: PictureBox Crashes

Post 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.
Danal
Posts: 43
Joined: Fri May 29, 2015 11:07 am
Location: Fairview, TX
Contact:

Re: PictureBox Crashes

Post 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.
sgraves
Posts: 30
Joined: Mon Jul 04, 2016 2:48 am
Location: Tampa, FL USA

Re: PictureBox Crashes

Post 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.
sgraves
Posts: 30
Joined: Mon Jul 04, 2016 2:48 am
Location: Tampa, FL USA

Re: PictureBox Crashes

Post 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.
Last edited by sgraves on Wed Jul 06, 2016 11:46 pm, edited 1 time in total.
Post Reply