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 / January 2004

Tip: Looking for answers? Try searching our database.

Reflection and Office PIA

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Alejandro Calbazana - 28 Jan 2004 15:09 GMT
Hello,

I was wondering if it is possible to do reflection when using objects
crated from the Office Primary Interop Assemblies.  I'd like to be
able to inspect properties of a few Excel objects at runtime.

Thanks,

Alejandro
Mattias Sj?gren - 28 Jan 2004 21:09 GMT
Alejandro,

>I was wondering if it is possible to do reflection when using objects
>crated from the Office Primary Interop Assemblies.  I'd like to be
>able to inspect properties of a few Excel objects at runtime.

Short answer; yes.

Mattias

Signature

Mattias Sjögren [MVP]  mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.

Alejandro Calbazana - 29 Jan 2004 17:23 GMT
> Short answer; yes.
>
> Mattias

Hmm...  What might the long answer be?  I'd like to know how this is done.

Alejandro
Mattias Sj?gren - 29 Jan 2004 20:42 GMT
Alejandro,

>Hmm...  What might the long answer be?  I'd like to know how this is done.

Well Reflection lets you inspect any assembly, including interop
assemblies. The procedure is the same regardless if the types are
imported from COM or not. So you should be able to look at any
reflection code sample and adapt it to the types you're interested in.

The only thing that's special when it comes to COM types is that when
you call GetType() on a RCW it may return the generic
System.__ComObject rather than a type from your interop assembly. This
happens if the interop assembly isn't registered (which it should be
if it's a PIA) and the object doesn't support IProvideClassInfo. See
the docs for Marshal.GetTypedObjectForIUnknown() and
Marshal.CreateWrapperOfType() for details.

Mattias

Signature

Mattias Sjögren [MVP]  mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.


Rate this thread:







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.