I have been working on an update of an integration engine that our company has built for a company in Denmark and currently focused on adding Office capabilities (Outlook, Excel …). Work has been going exceptionally well on the core infrastructure and I wrote the outlook connector during stops and plane trips back from Vegas on Saturday. Part of integrating with Office is the COM interop interfaces you have to use. Since the engine is supposed to be generic I wanted to write as little property access code as possible and determined that Reflection would be my best bet for the simplest code to do what is required.

So I rolled up my sleeves and worked away with PropertyInfo to get and set the object properties. To my dismay I was unable to get access to the underlying properties and no amount of casting or whining would work. Unfortunately I did not have internet access to see if anyone had gone to this dark place before me so I did what so many others have done before, Kludged a solution that worked but took way too many lines of code to implement and made me a little sick, but it worked and allowed me to prove out my design.

Well, I just got back to the engine now (3:25 am) and after looking at the code and knowing that it was not the right way to go I “Bing’d” Reflection of a COM object and lo and behold a post by Rick Strahl back in 2004 had the answer to my question.

Thanks Rick, you made my tummy happy and I can now feel more confident that I indeed have implemented the solution in a more elegant way.

Leave a Reply