ok, this is for a friend who doesn't seem to be able to reach codeguru forums for some reason, so i'm going to mediate

we're using c# to access a COM object, we have no idea what's inside it, we only have the interface. We manged to dynamically invoke a .NET assembly method (using the assembly, class and method names) and to get the output parameters, but whenever we try to invoke a method from a COM interface no output parameters are returned.

here's some code

================================================
string methodName = "MehtodName";



Type t = Type.GetTypeFromProgID("COM.ProgId");

object targetInstance = Activator.CreateInstance(t);



//Prepare input and output parameters

string param1 = "john";

long param2 = 0;

string param3 = "No Error";



object[] parameters = new object[]{param1, param2, param3};



//Set up the parameter modifiers.

//Order: pdIn, pdOut, pdLcid, pdRetval, pdOptional, and pdHasDefault

ParameterModifier inModifier = new ParameterModifier(1);

ParameterModifier outModifier = new ParameterModifier(2);



inModifier[0] = true;

outModifier[1] = true;



ParameterModifier[] modifiers = new ParameterModifier[3]{inModifier, outModifier, outModifier};



object ret = null;



try

{

//Invoke the target method

ret = t.InvokeMember(

methodName,

BindingFlags.Instance |

BindingFlags.Public |

BindingFlags.InvokeMethod,

null,

targetInstance,

parameters,

modifiers,

null,

null);

}

catch(System.Reflection.TargetInvocationException ex)

{

Log(ex.InnerException.ToString());

//exit the function

}



param2 = (long)parameters[1];

param3 = (string)parameters[2];



//do some work


================================================

awni