I wanted to call the GetIdsOfNames function from a COM object that implements the IDispatch interface in c#. I've written the following code but it fails with the DISP_E_UNKNOWNNAME. Is this the correct approach to do this?
Object so = Activator.CreateInstance(Type.GetTypeFromProgID("ProgID"));
Object[] args = new Object[5];
string[] rgsNames = new string[1];
rgsNames[0] = "PrintNormal";
uint LOCALE_SYSTEM_DEFAULT = 0x0800;
uint lcid = LOCALE_SYSTEM_DEFAULT;
int cNames = 1;
int[] rgDispId = new int[1];
args[0] = IntPtr.Zero;
args[1] = rgsNames;
args[2] = cNames;
args[3] = lcid;
args[4] = rgDispId;
Object result = so.GetType().InvokeMember("GetIDsOfNames", BindingFlags.InvokeMethod, null, so, args);
Thanks,
Richard