Home > Uncategorized > Com Reflection

Com Reflection

I read with interest this month’s MSDN magazine article on COM reflection.
The article provides an example of using reflection to uncover hidden
properties and methods of the Speech library, and also explains how the
elusive System.__ComObject can give up its goodies, so to speak.

It
works fine on the sample Speech API DLL on the site, however, it isn’t
so hot when it comes to Sage. I tried plugging in some common CLSID’s
from Sage’s inner workings, but it gave up no further information. I
then tried passing a System.__ComObject to it, with the following code;

Dim oUnknown As Object = o.GetCompanies("C:Program FilesSageAccounts")
DumpCOMObject(oUnknown)

However, it crashed out when IDispatch::GetTypeInfoCount returned 0. According to MSDN reference this is done to prevent run-time inspection of the DLL, perhaps for security purposes.

So,
I guess this is a bit of an anti-pattern when it comes to Sage
development, but I hope that this research saves another developer some
time when it comes to trying to figure out the million dollar question
‘what do I cast this object to now?

Advertisements
Categories: Uncategorized
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: