Type.GetProperties of Microsoft.Office.Interop.Excel.Range returns empty array

388 Views Asked by At

I want to get a list of properties of Microsoft.Office.Interop.Excel.Range interface using the following code:

using Excel = Microsoft.Office.Interop.Excel;
PropertyInfo[] info = typeof(Excel.Range).GetProperties();

but the result is an empty array: System.Reflection.PropertyInfo[0]

Am I missing something?

1

There are 1 best solutions below

1
On BEST ANSWER

Since VS2010, when importing the Office Primary Interop Assemblies (PIAs), the default mechanism for including the type definitions is to embed them as part of the main assembly instead of as separately referenced libraries (Dll). Part of this embedding process is the removal of unreferenced type members from the embedded definition.

In the Solution Explorer, expand the References node and select Interop.Microsoft.Office.Interop.Excel and then )right-click)->Show Properties. You should see something like this:

Property View Change "Embed Interop Types" to false, verify the "Copy Local" has also been automatically change to True. Do the same for "Interop.Microsoft.Office.Core" and "Interop.VBIDE".

Now when you reflect the managed wrapper interop types, you will get the complete type definition.