Click here to Skip to main content
15,903,175 members
Home / Discussions / COM
   

COM

 
QuestionCompile error says: "file not found: ..\lib\ScriptHost.tlb" Pin
nsurendran4-Jan-07 19:36
nsurendran4-Jan-07 19:36 
AnswerRe: Compile error says: "file not found: ..\lib\ScriptHost.tlb" Pin
User 2155975-Jan-07 0:26
User 2155975-Jan-07 0:26 
AnswerRe: Compile error says: "file not found: ..\lib\ScriptHost.tlb" Pin
Garth J Lancaster7-Jan-07 15:46
professionalGarth J Lancaster7-Jan-07 15:46 
QuestionGive me a simple MS COM object which raises events Pin
JoeRip4-Jan-07 17:23
JoeRip4-Jan-07 17:23 
AnswerRe: Give me a simple MS COM object which raises events Pin
User 2155975-Jan-07 0:20
User 2155975-Jan-07 0:20 
GeneralRe: Give me a simple MS COM object which raises events Pin
JoeRip5-Jan-07 0:45
JoeRip5-Jan-07 0:45 
GeneralRe: Give me a simple MS COM object which raises events Pin
User 2155975-Jan-07 3:36
User 2155975-Jan-07 3:36 
GeneralRe: Give me a simple MS COM object which raises events Pin
Mike Dimmick5-Jan-07 5:23
Mike Dimmick5-Jan-07 5:23 
JoeRip wrote:
Turns out that my event handlers for the COM object were not executing on the same thread as my form, and I was getting odd UI behavior as a result.


Awooga! Awooga!

Sorry, that's the sound of the alarm going off in my head.

Something's not right with your apartment setup. If you have forms, the thread that creates them should be marked with the [STAThread] attribute. This ensures that COM events are fired on the correct thread - it tells COM that this thread uses the apartment-threaded model (CoInitializeEx is called with the COINIT_APARTMENTTHREADED flag). Objects created by this thread have their calls sent back to this thread, regardless of which thread those calls were made from (if the object is implemented correctly).

The object is also marked for a given threading model - this is done in the registry for objects implemented as in-process servers (in DLLs). Normally automation objects are also marked apartment-threaded - this means that whichever thread you make a call to them on, COM will marshal the call to the thread you created the object on. However, COM can only do its stuff if you correctly marshal interface pointers between threads - if you just pass raw interface pointers around you can end up calling an object incorrectly on the wrong thread when it's not expecting it, causing unexpected race conditions or other thread-model violations. This is a particular problem if an event has to be raised by a worker thread.

This shouldn't happen if you're using an out-of-process object though, since those calls always need to be marshalled, which leads me to think that your UI thread isn't marked [STAThread].

Stability. What an interesting concept. -- Chris Maunder

GeneralRe: Give me a simple MS COM object which raises events Pin
JoeRip5-Jan-07 11:03
JoeRip5-Jan-07 11:03 
QuestionSinking HTMLWindowEvents2::OnUnload Pin
A_L4-Jan-07 15:34
A_L4-Jan-07 15:34 
Questionmatlab help ??? please Pin
ersincakir4-Jan-07 15:24
ersincakir4-Jan-07 15:24 
QuestionC# and COM - exporting enum-s Pin
Vitaly Tomilov4-Jan-07 0:42
Vitaly Tomilov4-Jan-07 0:42 
AnswerRe: C# and COM - exporting enum-s Pin
Pete O'Hanlon4-Jan-07 2:53
mvePete O'Hanlon4-Jan-07 2:53 
GeneralRe: C# and COM - exporting enum-s Pin
Vitaly Tomilov4-Jan-07 3:11
Vitaly Tomilov4-Jan-07 3:11 
GeneralRe: C# and COM - exporting enum-s Pin
Pete O'Hanlon5-Jan-07 3:30
mvePete O'Hanlon5-Jan-07 3:30 
Questionattaching com component to window (CWnd) Pin
praveen kumar agarwal3-Jan-07 20:38
praveen kumar agarwal3-Jan-07 20:38 
AnswerRe: attaching com component to window (CWnd) Pin
Aamir Butt3-Jan-07 20:45
Aamir Butt3-Jan-07 20:45 
Questionsend data with com port Pin
omidcomputer2-Jan-07 20:40
omidcomputer2-Jan-07 20:40 
AnswerRe: send data with com port Pin
CPallini2-Jan-07 21:12
mveCPallini2-Jan-07 21:12 
GeneralRe: send data with com port Pin
omidcomputer9-Jan-07 19:17
omidcomputer9-Jan-07 19:17 
GeneralRe: send data with com port Pin
CPallini9-Jan-07 20:42
mveCPallini9-Jan-07 20:42 
QuestionMy DLL is a normal API without any COM interface Pin
stellvia2-Jan-07 19:49
stellvia2-Jan-07 19:49 
AnswerRe: My DLL is a normal API without any COM interface Pin
CPallini2-Jan-07 21:14
mveCPallini2-Jan-07 21:14 
AnswerRe: My DLL is a normal API without any COM interface Pin
User 2155974-Jan-07 0:02
User 2155974-Jan-07 0:02 
QuestionSetting the position of a toolbar in IE Pin
georgekjolly29-Dec-06 23:45
georgekjolly29-Dec-06 23:45 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.