Not possible.
System.__COMObject
is a class declared as internal
and all its methods are exposed by System.Runtime.InteropServices.Marshal
. Therefore, this class is nothing more than a wrapper for the COM object, not having a derived .Net type that can be obtained by the Object.GetType()
method.
If you want to see more about this class, I recommend you take a look at the source code:
Editing:
According to your comment, what you want then is to get RTTI from the COM library. C # does not allow this kind of direct interaction with RTTI of non-manageable objects, so what to do?
1. What language your COM library was written to. It is usually C ++, but it can be written in Object Pascal too, for example.
2. Is the COM library compiled with RTTI? If not, there is nothing that can be done other than crying for the library developers to compile it with RTTI. Because? Because without RTTI, there is simply no way to do reflection on an object.
3. Build a library in the same language as your COM library that does the reflection for you. Using P / Invoke you interact with it within C #. Note that even then you will never have an object of type System.Type
, because this object only exists in manageable code, which is not the case with your COM library.
Maybe just to build a structure that encapsulates the std::type_info
returned by the typeid
operator (if it is the C ++ language of the COM library, of course), and build the methods to get this value from its COM class already enough .
The RTTI analysis library is not complicated (or does not seem to me at first), and needs only a few methods implemented, according to your need. Compared to the other solutions I've presented in the comments, it's a fraction of the complexity / effort, no doubt.