Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Interop / June 2005

Tip: Looking for answers? Try searching our database.

reflection with com

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
alexk - 27 Jun 2005 17:07 GMT
Hi,
Is reflection (e.g. GetField) is possible on a __ComObject ?

10x, Alex.
Michael Kremser - 27 Jun 2005 22:19 GMT
alexk schrieb:
> Hi,
> Is reflection (e.g. GetField) is possible on a __ComObject ?
>
> 10x, Alex.

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

Signature

http://www.mkcs.at/
The specified e-mail-address is valid and will be read.

alexk - 28 Jun 2005 04:54 GMT
> not known which interfaces the object implements). You can try to cast
> it to an interface, then you can do reflection on it too.

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)
Michael Kremser - 28 Jun 2005 06:59 GMT
alexk schrieb:

> AFAIK, you don't do refleciont on interfaces but on objects.

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

Signature

http://www.mkcs.at/
The specified e-mail-address is valid and will be read.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.