Hi
I have developed a smart client application. When i try to
execute it. It displays the first form which is the login
screen. On giving the corrent login id and password, the
main form opens. It has 2 menus. On clicking the submenu,
it throws an STAThread exception. The error details are
given below. I have included
System.Threading.Thread.CurrentThread.ApartmentSta te =
System.Threading.ApartmentState.STA;
above the static void Main(). Also my main has [STAThread]
above it.
Any idea as what must be the issue. Please help.
Error Description...
################################################## ###
************** Exception Text **************
System.InvalidOperationException: DragDrop registration
failed. ---> 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.Control.SetAcceptDrops(Boolea n
accept)
--- End of inner exception stack trace ---
at System.Windows.Forms.Control.SetAcceptDrops(Boolea n
accept)
at System.Windows.Forms.Control.OnHandleCreated
(EventArgs e)
at System.Windows.Forms.DataGrid.OnHandleCreated
(EventArgs e)
at System.Windows.Forms.Control.WmCreate(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.3300.0
Win32 Version: 1.0.3705.0
CodeBase:
file:///c:/winnt/microsoft.net/framework/v1.0.3705/mscorlib
..dll
----------------------------------------
IEExecRemote
Assembly Version: 1.0.3300.0
Win32 Version: 1.0.3705.0
CodeBase:
file:///c:/winnt/assembly/gac/ieexecremote/1.0.3300.0__b03f
5f7f11d50a3a/ieexecremote.dll
----------------------------------------
System
Assembly Version: 1.0.3300.0
Win32 Version: 1.0.3705.0
CodeBase:
file:///c:/winnt/assembly/gac/system/1.0.3300.0__b77a5c5619
34e089/system.dll
----------------------------------------
Problem_Reporting
Assembly Version: 1.0.1353.31384
Win32 Version: n/a
CodeBase:
http://inmum0129/ProblemReporting/Problem_Reporting.EXE
----------------------------------------
System.Windows.Forms
Assembly Version: 1.0.3300.0
Win32 Version: 1.0.3705.0
CodeBase:
file:///c:/winnt/assembly/gac/system.windows.forms/1.0.3300
..0__b77a5c561934e089/system.windows.forms.dll
----------------------------------------
System.Drawing
Assembly Version: 1.0.3300.0
Win32 Version: 1.0.3705.0
CodeBase:
file:///c:/winnt/assembly/gac/system.drawing/1.0.3300.0__b0
3f5f7f11d50a3a/system.drawing.dll
----------------------------------------
System.Xml
Assembly Version: 1.0.3300.0
Win32 Version: 1.0.3705.0
CodeBase:
file:///c:/winnt/assembly/gac/system.xml/1.0.3300.0__b77a5c
561934e089/system.xml.dll
----------------------------------------
System.Data
Assembly Version: 1.0.3300.0
Win32 Version: 1.0.3705.0
CodeBase:
file:///c:/winnt/assembly/gac/system.data/1.0.3300.0__b77a5
c561934e089/system.data.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.
################################################## ###
Thanks
Sonu