Home All Groups Group Topic Archive Search About

Reflection messing up the type hierarchy

Author
13 Sep 2006 3:26 PM
Emmanuel Stapf [ES]
Hi,

I've discovered in .NET 2.0 that for some reasons during reflection the
System.Object parent of a ComImport marked class is swapped with
System.__ComObject.

Here is a sample that shows this:
Assembly a = Assembly.LoadFrom(@"c:\Program Files
(x86)\Microsoft.NET\Primary Interop Assemblies\stdole.dll");
Type t = a.GetType("stdole.StdPictureClass");
bool b = t.Equals (typeof (object))

b is False.

What is very annoying moreover is that when you ask whether
System.__ComObject is public in mscorlib you get `false', but when you do it
it when querying the BaseType of `t' you get `true'.

Any insight here? What is the rational for changing the hierarchy since in
ildasm it only shows System.Object. I understand that at runtime it might be
magically swapped to be System.__ComObject, but Reflection is not about
runtime, it is about introspection of assemblies.

Thanks for any insights,
Manu

AddThis Social Bookmark Button