A long title, but I wanted it to be specific. The title is really the question. Even though the method that InvokeMember
is calling has an out
pa
I just wanted to help someone who is struggling(I did) with unmanaged(COM) and getting ref-parameter back. So, when using InvokeMember against COM-method, you have to tell which arguments are ref-type. This is achieved by using ParameterModifier-class, For example:
object[] args = new object[3] { param1, param2, errorStr };
ParameterModifier pMod = new ParameterModifier(3);
pMod[2] = true;
ParameterModifier[] mods = { pMod };
object tempObj = myCOMObject.GetType().InvokeMember("MyCOMMethod", BindingFlags.InvokeMethod | BindingFlags.NonPublic | BindingFlags.Public, null, myCOMObject, args, mods, null, null);
In the code above, the 3rd argument is set to be a reference (pMod[2] = true;)