Niccolo
Niccolo

Reputation: 401

.NET is there a way to discover the members of a COM-object

In our WPF-application that is hosted in IE we are retrieving some context info from a COM-object which has the type of System.__ComObject (JScriptTypeInfo). We retrieve data from it using its type:

Type type = obj.GetType();
object value = type.InvokeMember(name, BindingFlags.GetProperty | BindingFlags.IgnoreCase, null, obj, null);

where name is the property we want to retrieve. The problem is that some properties are retrieved but some are not - an exception is thrown (System.Runtime.InteropServices.COMException (0x80020006): Unknown name. (Exception from HRESULT: 0x80020006 (DISP_E_UNKNOWNNAME))

So is it possible to retrieve the names of all the properties of this COM-object and how?

TIA

Upvotes: 0

Views: 1599

Answers (1)

Sheng Jiang 蒋晟
Sheng Jiang 蒋晟

Reputation: 15281

A sample to use ITypeInfo to get the type information of an automation object in .Net can be found at Inspecting COM Objects With Reflection

Upvotes: 1

Related Questions