{"id":3853,"date":"2008-10-12T12:00:00","date_gmt":"2008-10-12T12:00:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/vbteam\/2008\/10\/12\/reflection-on-com-objects-lucian-wischik\/"},"modified":"2024-07-05T14:06:29","modified_gmt":"2024-07-05T21:06:29","slug":"reflection-on-com-objects-lucian-wischik","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/vbteam\/reflection-on-com-objects-lucian-wischik\/","title":{"rendered":"Reflection on COM objects (Lucian Wischik)"},"content":{"rendered":"<p>Reflection on .Net objects is done through System.Type and is very easy. For instance, &#8220;Dim type = GetType(System.String)&#8221; and now you can look at all the members and inheritance hierarchy of the System.String class.<\/p>\n<p>Reflection on&nbsp;COM types is also easy if they have an <em>interop assembly<\/em>. For instance, add a project reference to the COM Microsoft Speech Library and again do &#8220;GetType(SpeechLib.SpVoice)&#8221;. This lets you reflect on the .Net&nbsp;&#8220;Runtime Callable Wrapper&#8221;&nbsp;that&#8217;s in the interop assembly, that was generated from the COM type&#8217;s type library, and that contains all information that the type library had.<\/p>\n<p>But sometimes you&#8217;ll be given COM objects that don&#8217;t have .Net interop assemblies in your code. I ran into this when I wrote a managed plugin for Visual Studio. For reflection here you have to use ITypeInfo instead of System.Type.&nbsp;Here&#8217;s code to get that ITypeInfo, then dig through it and print out all the members. I&#8217;m a novice at COM programming, so I&#8217;d welcome suggestions and improvements.<\/p>\n<p>&#8230;.<\/p>\n<p>[ the rest of this post is on my new vblog, <a href=\"http:\/\/blogs.msdn.com\/lucian\">http:\/\/blogs.msdn.com\/lucian<\/a> ]<\/p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Reflection on .Net objects is done through System.Type and is very easy. For instance, &#8220;Dim type = GetType(System.String)&#8221; and now you can look at all the members and inheritance hierarchy of the System.String class. Reflection on&nbsp;COM types is also easy if they have an interop assembly. For instance, add a project reference to the COM [&hellip;]<\/p>\n","protected":false},"author":260,"featured_media":8818,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[21,195],"tags":[99],"class_list":["post-3853","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-im-a-vb","category-visual-basic","tag-lucian-wischik"],"acf":[],"blog_post_summary":"<p>Reflection on .Net objects is done through System.Type and is very easy. For instance, &#8220;Dim type = GetType(System.String)&#8221; and now you can look at all the members and inheritance hierarchy of the System.String class. Reflection on&nbsp;COM types is also easy if they have an interop assembly. For instance, add a project reference to the COM [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/vbteam\/wp-json\/wp\/v2\/posts\/3853","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/vbteam\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/vbteam\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/vbteam\/wp-json\/wp\/v2\/users\/260"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/vbteam\/wp-json\/wp\/v2\/comments?post=3853"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/vbteam\/wp-json\/wp\/v2\/posts\/3853\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/vbteam\/wp-json\/wp\/v2\/media\/8818"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/vbteam\/wp-json\/wp\/v2\/media?parent=3853"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/vbteam\/wp-json\/wp\/v2\/categories?post=3853"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/vbteam\/wp-json\/wp\/v2\/tags?post=3853"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}