COM Apartments

Whether you register a managed object using the Assembly Registration Tool (regasm) or you use one of the activation functions that do not require registration, like ClrCreateManagedInstance, a managed object behaves like a COM object with the Both threading model when called from an unmanaged client. In other words, the object will run on the same thread as its caller whether the calling thread resides within an STA or an MTA. The implication of this is that, if you are going to call a managed object from a multithreaded unmanaged client, you need to make sure that the managed object is thread safe. With COM, if you did not want to write thread synchronization code, you could simply specify that your object use an STA. With the ...

Get .NET and COM Interoperability Handbook, The now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.