I have, Windows Form, which have System.Timers.Timer in elapsed event of this timer, I wish to popup a form using ShowDialog(), over there while creating object of that form itself, I am getting following error.
Current thread must be set to single thread apartment (STA) mode before OLE calls can be made
As suggested in some other SO post, I had decorated Main() which initializes this form with [STAThread] attribute.
But still getting same error, now when I debug, exception is generated at,
this.TheDropDownObject.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.SuggestAppend;
where I set AutoCompleteMode of Dropdown control in that form,
As suggested in yet another SO post, I had done this through code instead of in designer but tough luck.
Now Suppose, I create object on some other event then it is working, else if skip setting this AutoCompleteMode then still it is triggered from timer.
Can anyone please tell me what is going wrong, and how can I get this achieved?