I am using late binding to call a method in a COM object. There are three ref arguments in this function. I used ParameterModifier class to indicate this. The problem is that I am expecting the third argument to get a value but it get nothing. The function does succeed.
The method signature according to the documentation:
Code:
public virtual int Create(ref object XMLSource, ref bool ModifyIfExists, ref string CptNumGenerated)
The method where I call this function.
Code:
public int AddHoursEntry(string xml)
{
int result = 0;
if (IsConnectedToDatabase)
{
object hoursEntry = this.InterfaceType.InvokeMember("HoursEntry", BindingFlags.GetProperty, null, this.MaestroObject, null);
if (hoursEntry != null)
{
string cpt = "0";
bool modify = false;
object[] args = {xml, modify, cpt};
ParameterModifier p = new ParameterModifier(3);
p[0] = true;
p[1] = true;
p[2] = true;
ParameterModifier[] mods = { p };
result = (int)hoursEntry.GetType().InvokeMember("Create",
BindingFlags.InvokeMethod,
null,
hoursEntry,
args,
mods,
null,
null);
if (result == 0)
result = Convert.ToInt32(cpt); // Expecting the cpt value to be > 0
else
{
object errorObj = this.interfaceType.InvokeMember("GetErrors", BindingFlags.InvokeMethod, null, this.MaestroObject, null);
if (errorObj != null)
{
this.LastError = (string)errorObj.GetType().InvokeMember("XML", BindingFlags.GetProperty, null, errorObj, null);
}
else
this.LastError = "Error unknown!";
}
}
}
return result;
}
Can anyone see anything I am doing wrong?
Mike B