Will COM marshalling (ever) be necessary for an object with ThreadingModel Both?

This is caused by another question .

In particular, I have a COM class in the process that is defined in of . ThreadingModelBoth

Our process activates this object through (not if it matters to the in-proc dll server) CoCreateInstanceCoCreateInstanceEx

Given the stream model Bothand predefined rules listed in the docs :

Threading model of server | Apartment server is run in
------------------------------------------------------
Both                      | Same apartment as client

and given what Hans writes in another answer:

... Marshaling occurs when a client call must be made to another thread .... it can happen if the ThreadingModel specified in the comClass element requires this. In other words, when a COM object was created in one thread, but called on another, and the server is not thread safe.

, , , .

, STA?

+4
4

, .

COM- STA , , .

COM . "" , , ( ).

Both , , . , , , . STA, STA, , ; , , .

+6

, .

MSKB COM: INFO: OLE. . , , , . ThreadingModel=Both, Free-Threaded Marshaler CoCreateFreeThreadedMarshaler . COM , , . , .

"" , , , . , , .

"" , CoMarshalInterThreadInterfaceInStream/CoGetInterfaceAndReleaseStream:

:

  • ;
  • CoMarshalInterThreadInterfaceInStream IStream ;

  • ;
  • CoGetInterfaceAndReleaseStream
  • CoMarshalInterThreadInterfaceInStream IStream

:

  • , IStream ( ).

"" , , , , CoGetInterfaceAndReleaseStream. - , , , , - COM-.

, CoMarshalInterface w/MSHLFLAGS_TABLESTRONG/CoUnmarshalInterface/IStream::Seek(0, 0)/CoReleaseMarshalData CoGetInterfaceAndReleaseStream/CoGetInterfaceAndReleaseStream, , .

(, , ) , . , . , , CoMarshalInterThreadInterfaceInStream/CoGetInterfaceAndReleaseStream .

, , , , COM-, ThreadingModel=Both FTM.

+3

, - . :

  • MTA MTA, STA STA . STA .

  • STA STA, , STA MTA. .

:

  • MTA, MTA - , MTA .
  • STA,

.

+2

ThreadingModel = , COM- , , , , , - . , - ( "" ).

, STA, , . , , . , .

+1

All Articles