From: Fazil Peermohammed on
I'm writing a generic application that can read any .NET object which is a
wrapper on COM object (such as MS Exel 2007). I create the class in C# like

ApplicationClass app = new ApplicationClass(); // the Excel application.

System.Reflection.PropertyInfo w = app.GetType().GetProperty("Workbooks");

Object Objbooks= w.GetValue(app, null);

Objbooks is now a System.__ComObject. My objective is to convert this to a
System.Object that represents Microsoft.Office.Interop.Excel.Workbooks. To
do this in C#, I would do

Microsoft.Office.Interop.Excel.Workbooks WorkBooks =

WorkBooks has all the properties and methods of Workbooks. How do I write
this casting algorithm dynamically so that I dont have to hard code any

I've found a way to find the Type that represents
Microsoft.Office.Interop.Excel.Workbooks, but I just can't figure out how to
cast Objbooks to a System.Object of

I tried the generic method and reflection approach gievn in few sites, but I
still get a System.__ComObject without the properties of Workbooks.