When we define a COM interface in MIDL (Microsoft Interface Decription Language), we should utilize the oleautomation compatible data types. These types could be recognized by the COM aware languages.
Suddenly, the .NET CTS (Common Type Specification) flashed into my mind. The CTS is the minimum subset of types that any .NET compatible language must respect.
Aren’t the CTS and oleautomation compatible types very similar? Does the CTS evolve from oleautomation compatible types?
Many thanks.
Well, not really. The set of types compatible with oleauto is rather restrictive so it isn’t particularly surprising that there’s a one-to-one mapping with managed (value) types. But important oleauto types like VARIANT, SAFEARRAY, IDispatch* and HRESULT have no direct mapping. That they actually can be mapped to, respectively, object, System.Array, __ComObject and System.Exception is thanks to the COM interop built into the CLR. That’s cold hard code that is not in any way prescribed by the CTS.