COM - Component Object Model

  • What is Marshaling? Describe how BSTRs are marshalled as [in], [out] and [in,out] parameters.

  • What is the reason for calling CoInitialize() and CoUninitialize()?
  • Describe the various COM threading models
    Single threading model pre-dates apartment models and these server objects run directly within the main thread of the calling thread. Apartment threaded server objects are meant to be run on their own thread. These do not protect themselves from concurrent accesses. Both and Free are threading models where the server object protects its sensitive data from concurrent accesses. Hence these can be run in multi threaded apartments. An object marked with the Both threading model can also be run in a STA without any performance degradation. On the other hand, a server object marked Free will cause severe performance degradation if run in a STA. This is because the free threaded object spawns worker threads which perform most of the client requests. These worker threads will require frequent accesses to the main object. These objects use synchronization and hence work best in a MTA environment. On the other hand, if these are run in STAs, each access across threads will have to go through the marshaler (and a windows message loop in each STA), causing significant performance degradation.

  • Describe Early and Late binding.