all groups > dotnet interop > june 2005 >
You're in the

dotnet interop

group:

reflection with com



reflection with com alexk
6/27/2005 9:07:21 AM
dotnet interop: Hi,
Is reflection (e.g. GetField) is possible on a __ComObject ?

10x, Alex.
Re: reflection with com alexk
6/27/2005 8:54:10 PM

[quoted text, click to view]

Michael, thank you for your answer.

AFAIK, you don't do refleciont on interfaces but on objects.
So I believe your suggestion won't work, e.g.
PrpertyInfo pi = typeof(IInterface).GetProperty(fieldName,
_BindingFlags.Instance Or BindingFlags.Public);
pi.GetValue(obj,Nothing)
Re: reflection with com Michael Kremser
6/27/2005 11:19:36 PM
alexk schrieb:
[quoted text, click to view]

Hi Alex,

no, because a __ComObject means that it is just any COM object (it is
not known which interfaces the object implements). You can try to cast
it to an interface, then you can do reflection on it too.

HTH,

Michael

--
http://www.mkcs.at/
Re: reflection with com Michael Kremser
6/28/2005 7:59:19 AM
alexk schrieb:
[quoted text, click to view]

That's right. I wrote you have to *cast* to an interface, just like this:

IInterface ii = obj as IInterface;
If (ii!=null)
{
PropertyInfo pi =
ii.GetType().GetProperty(fieldName,BindingFlags.Instance |
BindingFlags.Public);
object oValue = pi.GetValue(obj,null);
}

HTH,

Michael

--
http://www.mkcs.at/
AddThis Social Bookmark Button