How return the type of a System.__COMObject in System.Type in C#
I did not use reflection as I wished, but it is working pretty fine.
foreach(PropertyDescriptor descrip in TypeDescriptor.GetProperties(COMObject))
{
if(descrip.Name == "Attribute Name")
{
foreach(PropertyDescriptor descrip2 in TypeDescriptor.GetProperties(descrip))
{
if(descrip2.Name == "sub attribute Name")
{
}
}
}
}
This code returns the name of the attributes, for example, imagine that my COMObject has this attributes:
int age;
string name;
Son Phill;
and Son has:
int age;
string name;
In the first loop, the descrip.Name will be "age", "name" and "Phill", and in the second (suppose that the condition returns true for "Son"), "age" and "name".