K
Ken Varn
I have a multi-threaded managed MFC C++ application that is using GDI+
through .NET.
I am loading successive JPEGs into a Bitmap object in one thread and
displaying them into a Windows Forms PictureBox control in another thread.
Mutexs have been put in place to protect the Bitmap object and PictureBox
from possible collision. However, I occasionally getting an unhandled
Windows Forms exception that I cannot seem to locate and it is baffling me
because the stack trace does not show any of my code layers. This exception
is highly unpredictable, and ususally occurs when the application is run for
the first time (Maybe before the IL is converted to native by JIT).
The exception is below. I am hoping that someone might see something
familiar here and could explain why this is happenning. Note that the
managed C++ application also has a main native MFC dialog window that
displays a managed .NET forms window.
The exception dump is as follows:
************** Exception Text **************
System.InvalidOperationException: The object is currently in use elsewhere.
at System.Drawing.Graphics.EndContainer(GraphicsContainer container)
at
System.Windows.Forms.DibGraphicsBufferManager.ReleaseBuffer(GraphicsBuffer
buffer)
at System.Windows.Forms.GraphicsBuffer.Dispose()
at System.Windows.Forms.Control.WmPaint(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg,
IntPtr wparam, IntPtr lparam)
************** Loaded Assemblies **************
mscorlib
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase:
file:///c:/winnt/microsoft.net/framework/v1.1.4322/mscorlib.dll
----------------------------------------
LogFile
Assembly Version: 0.0.0.0
Win32 Version: 1, 0, 0, 1
CodeBase: file:///C:/dvr/LogFile.dll
----------------------------------------
DVR
Assembly Version: 0.0.0.0
Win32 Version: 2.0.0.0
CodeBase: file:///C:/dvr/dvr.exe
----------------------------------------
System
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase:
file:///c:/winnt/assembly/gac/system/1.0.5000.0__b77a5c561934e089/system.dll
----------------------------------------
FrameGrabber
Assembly Version: 0.0.0.0
Win32 Version: 1.0.0.1
CodeBase: file:///C:/dvr/FrameGrabber.DLL
----------------------------------------
Microsoft.VisualC
Assembly Version: 7.0.5000.0
Win32 Version: 7.10.3052.4
CodeBase:
file:///c:/winnt/assembly/gac/microsoft.visualc/7.0.5000.0__b03f5f7f11d50a3a/microsoft.visualc.dll
----------------------------------------
System.Drawing
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase:
file:///c:/winnt/assembly/gac/system.drawing/1.0.5000.0__b03f5f7f11d50a3a/system.drawing.dll
----------------------------------------
System.Data
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase:
file:///c:/winnt/assembly/gac/system.data/1.0.5000.0__b77a5c561934e089/system.data.dll
----------------------------------------
System.Xml
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase:
file:///c:/winnt/assembly/gac/system.xml/1.0.5000.0__b77a5c561934e089/system.xml.dll
----------------------------------------
GDIPlusEx
Assembly Version: 1.0.1495.16797
Win32 Version: 1.0.1495.16797
CodeBase: file:///C:/dvr/GDIPlusEx.DLL
----------------------------------------
System.Runtime.Remoting
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase:
file:///c:/winnt/assembly/gac/system.runtime.remoting/1.0.5000.0__b77a5c561934e089/system.runtime.remoting.dll
----------------------------------------
DVRGUI
Assembly Version: 1.0.1495.16885
Win32 Version: 1.0.1495.16885
CodeBase: file:///C:/dvr/DVRGUI.DLL
----------------------------------------
System.Windows.Forms
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase:
file:///c:/winnt/assembly/gac/system.windows.forms/1.0.5000.0__b77a5c561934e089/system.windows.forms.dll
----------------------------------------
************** JIT Debugging **************
To enable just in time (JIT) debugging, the config file for this
application or machine (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 machine
rather than being handled by this dialog.
--
-----------------------------------
Ken Varn
Senior Software Engineer
Diebold Inc.
EmailID = varnk
Domain = Diebold.com
-----------------------------------
through .NET.
I am loading successive JPEGs into a Bitmap object in one thread and
displaying them into a Windows Forms PictureBox control in another thread.
Mutexs have been put in place to protect the Bitmap object and PictureBox
from possible collision. However, I occasionally getting an unhandled
Windows Forms exception that I cannot seem to locate and it is baffling me
because the stack trace does not show any of my code layers. This exception
is highly unpredictable, and ususally occurs when the application is run for
the first time (Maybe before the IL is converted to native by JIT).
The exception is below. I am hoping that someone might see something
familiar here and could explain why this is happenning. Note that the
managed C++ application also has a main native MFC dialog window that
displays a managed .NET forms window.
The exception dump is as follows:
************** Exception Text **************
System.InvalidOperationException: The object is currently in use elsewhere.
at System.Drawing.Graphics.EndContainer(GraphicsContainer container)
at
System.Windows.Forms.DibGraphicsBufferManager.ReleaseBuffer(GraphicsBuffer
buffer)
at System.Windows.Forms.GraphicsBuffer.Dispose()
at System.Windows.Forms.Control.WmPaint(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg,
IntPtr wparam, IntPtr lparam)
************** Loaded Assemblies **************
mscorlib
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase:
file:///c:/winnt/microsoft.net/framework/v1.1.4322/mscorlib.dll
----------------------------------------
LogFile
Assembly Version: 0.0.0.0
Win32 Version: 1, 0, 0, 1
CodeBase: file:///C:/dvr/LogFile.dll
----------------------------------------
DVR
Assembly Version: 0.0.0.0
Win32 Version: 2.0.0.0
CodeBase: file:///C:/dvr/dvr.exe
----------------------------------------
System
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase:
file:///c:/winnt/assembly/gac/system/1.0.5000.0__b77a5c561934e089/system.dll
----------------------------------------
FrameGrabber
Assembly Version: 0.0.0.0
Win32 Version: 1.0.0.1
CodeBase: file:///C:/dvr/FrameGrabber.DLL
----------------------------------------
Microsoft.VisualC
Assembly Version: 7.0.5000.0
Win32 Version: 7.10.3052.4
CodeBase:
file:///c:/winnt/assembly/gac/microsoft.visualc/7.0.5000.0__b03f5f7f11d50a3a/microsoft.visualc.dll
----------------------------------------
System.Drawing
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase:
file:///c:/winnt/assembly/gac/system.drawing/1.0.5000.0__b03f5f7f11d50a3a/system.drawing.dll
----------------------------------------
System.Data
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase:
file:///c:/winnt/assembly/gac/system.data/1.0.5000.0__b77a5c561934e089/system.data.dll
----------------------------------------
System.Xml
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase:
file:///c:/winnt/assembly/gac/system.xml/1.0.5000.0__b77a5c561934e089/system.xml.dll
----------------------------------------
GDIPlusEx
Assembly Version: 1.0.1495.16797
Win32 Version: 1.0.1495.16797
CodeBase: file:///C:/dvr/GDIPlusEx.DLL
----------------------------------------
System.Runtime.Remoting
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase:
file:///c:/winnt/assembly/gac/system.runtime.remoting/1.0.5000.0__b77a5c561934e089/system.runtime.remoting.dll
----------------------------------------
DVRGUI
Assembly Version: 1.0.1495.16885
Win32 Version: 1.0.1495.16885
CodeBase: file:///C:/dvr/DVRGUI.DLL
----------------------------------------
System.Windows.Forms
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase:
file:///c:/winnt/assembly/gac/system.windows.forms/1.0.5000.0__b77a5c561934e089/system.windows.forms.dll
----------------------------------------
************** JIT Debugging **************
To enable just in time (JIT) debugging, the config file for this
application or machine (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 machine
rather than being handled by this dialog.
--
-----------------------------------
Ken Varn
Senior Software Engineer
Diebold Inc.
EmailID = varnk
Domain = Diebold.com
-----------------------------------