Currently my app is STAThread in the Sub Main of the assembly that uses
the Clipboard.SetDataOjbect method as shown here:
Module modBase
<STAThread()> Public Sub Main()
Try
Application.Run(New frmScaleImage)
Catch ex As Exception
Dim strError As String
If gblnTEST_MODE Then
strError = "TESTMODE: frmInput.Main()"
Else
strError = "frmInput.Main()"
End If
WriteToEventLog(strError, ex.ToString)
MsgBox("An unexpected application error has occurred." &
vbCrLf & vbCrLf & _
"Please leave this message on the screen and
call a programmer." & _
strError & vbCrLf & vbCrLf & ex.ToString)
End Try
End Sub
My Catch didn't 'catch' this error either.
The app worked fine today for a while but just now blew up. This is why
I am saying that the consistency if frustrating.
This is the error I got today when using the app:
See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.
************** Exception Text **************
System.Threading.ThreadStateException: The current thread must set to
Single Thread Apartment (STA) mode before OLE calls can be made. Ensure
that your Main function has STAThreadAttribute marked on it.
at System.Windows.Forms.Clipboard.SetDataObject(Object data, Boolean
copy)
at System.Windows.Forms.Clipboard.SetDataObject(Object data)
at ScaleImage.frmScaleImage.tdbgData_Click(Object sender, EventArgs
e)
at System.Windows.Forms.Control.OnClick(EventArgs e)
at C1.Win.C1TrueDBGrid.BaseGrid.Frame.OnClick(EventArgs e)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons
button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at C1.Win.C1TrueDBGrid.C1TrueDBGrid.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:/windows/microsoft.net/framework/v1.1.4322/mscorlib.dll
----------------------------------------
System.Drawing
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase:
file:///c:/windows/assembly/gac/system.drawing/1.0.5000.0__b03f5f7f11d50
a3a/system.drawing.dll
----------------------------------------
System
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase:
file:///c:/windows/assembly/gac/system/1.0.5000.0__b77a5c561934e089/syst
em.dll
----------------------------------------
RegexAssembly8_0
Assembly Version: 0.0.0.0
Win32 Version: n/a
CodeBase:
----------------------------------------
IEExecRemote
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase:
file:///c:/windows/assembly/gac/ieexecremote/1.0.5000.0__b03f5f7f11d50a3
a/ieexecremote.dll
----------------------------------------
Stub
Assembly Version: 1.0.1525.15805
Win32 Version: n/a
CodeBase:
http://intranet.taglab.org/TMR/ScaleApps/Stub.EXE
----------------------------------------
System.Windows.Forms
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase:
file:///c:/windows/assembly/gac/system.windows.forms/1.0.5000.0__b77a5c5
61934e089/system.windows.forms.dll
----------------------------------------
System.Xml
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase:
file:///c:/windows/assembly/gac/system.xml/1.0.5000.0__b77a5c561934e089/
system.xml.dll
----------------------------------------
Microsoft.VisualBasic
Assembly Version: 7.0.5000.0
Win32 Version: 7.10.3052.4
CodeBase:
file:///c:/windows/assembly/gac/microsoft.visualbasic/7.0.5000.0__b03f5f
7f11d50a3a/microsoft.visualbasic.dll
----------------------------------------
ScaleImage
Assembly Version: 1.1.1525.25632
Win32 Version: n/a
CodeBase:
http://intranet.taglab.org/TMR/ScaleApps/ScaleImage.DLL
----------------------------------------
C1.Win.C1TrueDBGrid
Assembly Version: 1.2.20033.30829
Win32 Version: 1.2.20034.31024
CodeBase:
file:///c:/windows/assembly/gac/c1.win.c1truedbgrid/1.2.20033.30829__75a
e3fb0e2b1e0da/c1.win.c1truedbgrid.dll
----------------------------------------
System.Data
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase:
file:///c:/windows/assembly/gac/system.data/1.0.5000.0__b77a5c561934e089
/system.data.dll
----------------------------------------
C1.Common
Assembly Version: 1.0.20031.116
Win32 Version: 1.0.20031.117
CodeBase:
file:///c:/windows/assembly/gac/c1.common/1.0.20031.116__e272bb32d11b194
8/c1.common.dll
----------------------------------------
Accessibility
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase:
file:///c:/windows/assembly/gac/accessibility/1.0.5000.0__b03f5f7f11d50a
3a/accessibility.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.