Error occur when load form

  • Thread starter Thread starter Jeff0803
  • Start date Start date
J

Jeff0803

Guest
From the timer, call a static method which load a form like following.

if (chattingsession == null)//Chatting is not opened yet
{
chattingsession = new ChattingSession(incomingphoneno, first_name, last_name);
newform = true;
}

chattingsession.Name = incomingphoneno;
chattingsession.MessageList = messagelist;
chattingsession.MessageList.Add(msg);
chattingsessionlist.Add(chattingsession);
if (newform)
{
chattingsession.Show();
}

howevr error occurs like following. Can anybody give me some advice?


************** Exception Text **************
System.InvalidOperationException: DragDrop registration did not succeed. ---> System.Threading.ThreadStateException: Current thread must be 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(Boolean accept)
--- End of inner exception stack trace ---
at System.Windows.Forms.Control.SetAcceptDrops(Boolean accept)
at System.Windows.Forms.Control.OnHandleCreated(EventArgs e)
at System.Windows.Forms.TextBoxBase.OnHandleCreated(EventArgs e)
at System.Windows.Forms.TextBox.OnHandleCreated(EventArgs e)
at System.Windows.Forms.Control.WmCreate(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.TextBoxBase.WndProc(Message& m)
at System.Windows.Forms.TextBox.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

Continue reading...
 

Similar threads

M
Replies
0
Views
114
Mani25
M
G
Replies
0
Views
160
Graham Skan
G
D
Replies
0
Views
91
Decompressor
D
Back
Top