473,396 Members | 1,996 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

STAThread Exception

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
Nov 22 '05 #1
0 912

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: sonu | last post by:
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....
11
by: warren | last post by:
Hello, Anyone can brief me what is this in front of the Main method for? and when must it be there, and when is it optional? thank you.
3
by: Justine | last post by:
hi all, i just want to know the significance of in the C# application. Why & for What reason is this used. Thanz in Advance, Justine
9
by: | last post by:
Hi All, I have allready tried to ask a similar question , but got no answer until now. In the meantime, I found, that I cannot understand some thread-settings for the Main() function . If I use...
1
by: Nadav | last post by:
Hi, I am using ‘CorBindToRuntimeEx’ To create a runtime host and execute an assembly: hr = CorBindToRuntimeEx(. . .) hr = spICorRuntimeHost->CurrentDomain(&spUnk); spIAppDomain = spUnk;...
2
by: Tom | last post by:
Do we need to put the STAThread attribute on our Sub Main anymore if we are using the 1.1 Framework? See some YEAs and NEAs when searching on Google so thought I would ask here. Tom
0
by: renfes | last post by:
Hey everyone. I have a program that watches a .txt log file from a chat client or a game and based on each line, triggers events. One thing I am trying to do is send the contents of a text file to...
1
by: Sefner | last post by:
Hey everyone. I have a program that watches a .txt log file from a chat client or a game and based on each line, triggers events. One thing I am trying to do is send the contents of a text file to...
12
by: rafalK | last post by:
Hi All, I have a big problem with STAThread attribute. I'm using XNA framework connected with WinForms. XNA is working in non STAThread. I have a problem with displaying CommonDialog forms e.g....
2
by: =?Utf-8?B?QWxoYW1icmEgRWlkb3MgS2lxdWVuZXQ=?= | last post by:
Hi misters, I have introduced a component to my solution that is throwing an exception about needing to be run in single threaded apartment mode. This component is created in an async call by...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.