STAThread Exception

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • sonu

    #1

    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.Threadin g.Thread.Curren tThread.Apartme ntState =
    System.Threadin g.ApartmentStat e.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.InvalidO perationExcepti on: DragDrop registration
    failed. ---> System.Threadin g.ThreadStateEx ception: The
    current thread must set to Single Thread Apartment (STA)
    mode before OLE calls can be made. Ensure that your Main
    function has STAThreadAttrib ute marked on it.
    at System.Windows. Forms.Control.S etAcceptDrops(B oolean
    accept)
    --- End of inner exception stack trace ---
    at System.Windows. Forms.Control.S etAcceptDrops(B oolean
    accept)
    at System.Windows. Forms.Control.O nHandleCreated
    (EventArgs e)
    at System.Windows. Forms.DataGrid. OnHandleCreated
    (EventArgs e)
    at System.Windows. Forms.Control.W mCreate(Message & m)
    at System.Windows. Forms.Control.W ndProc(Message& m)
    at System.Windows. Forms.ControlNa tiveWindow.OnMe ssage
    (Message& m)
    at System.Windows. Forms.ControlNa tiveWindow.WndP roc
    (Message& m)
    at System.Windows. Forms.NativeWin dow.Callback(In tPtr
    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__b03 f
    5f7f11d50a3a/ieexecremote.dl l
    ----------------------------------------
    System
    Assembly Version: 1.0.3300.0
    Win32 Version: 1.0.3705.0
    CodeBase:
    file:///c:/winnt/assembly/gac/system/1.0.3300.0__b77 a5c5619
    34e089/system.dll
    ----------------------------------------
    Problem_Reporti ng
    Assembly Version: 1.0.1353.31384
    Win32 Version: n/a
    CodeBase:

    ----------------------------------------
    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__b77a5c5619 34e089/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__b77 a5c
    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__b77 a5
    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:

    <configuratio n>
    <system.windows .forms jitDebugging="t rue" />
    </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
Working...