![]() |
If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
![]()
Hello,
I wasn't getting this error until I threw my code, which initiated/called my Form to load, into a try/catch statement. "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." I don't have a Main function in my code for my COM add-in for Outlook, so how would I go about fixing this error so that I can load my Form. Thanks |
#2
|
|||
|
|||
![]()
That error usually occurs in relation to WordMail objects in Outlook 2003 or
earlier. In that case WordMail is not running in the same process space as Outlook is and the threading is different. It also can happen from background threads (which never, ever should be used to access the Outlook object model). Your Connect class is running in process with Outlook and in the same thread. You would need to set up a callback into the main thread. I usually get the current thread context in Connect, at NewInspector() and NewExplorer(). Often to prime the message pump I call System.Windows.Forms.Application.DoEvents() before I get the context so it isn't null. I then store that context and put any thread sensitive code in Connect so it runs in the main thread. When I need to synch to that thread I use a System.Threading.SendOrPostCallback utilizing the persisted main thread context. -- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Professional Programming Outlook 2007. Reminder Manager, Extended Reminders, Attachment Options. http://www.slovaktech.com/products.htm "Matt" wrote in message ... Hello, I wasn't getting this error until I threw my code, which initiated/called my Form to load, into a try/catch statement. "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." I don't have a Main function in my code for my COM add-in for Outlook, so how would I go about fixing this error so that I can load my Form. Thanks |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Outlook SP2 Cached mode.Opening shared calendar-Permission error | Didier | Outlook - Calandaring | 0 | June 7th 07 09:20 PM |
Error: Rejected Safe Mode action : Microsoft Office Outlook. | Ryan Close | Outlook - Installation | 0 | December 13th 06 02:19 PM |
what does error code office in off line mode mean{Outlook} | dapperz | Outlook - Installation | 1 | November 8th 06 04:17 PM |
how do i change outlook 2003 back to regular mode from "safe mode | CCSMUDGE | Outlook - Installation | 0 | July 5th 06 01:26 AM |
Cached Exchange Mode Terminal Services Error | Dennis Procopio | Outlook - Installation | 7 | June 14th 06 04:27 PM |