EduPro

PI-SDK C# PIData.UpdateValue Type mismatch (HRESULT: 0x80020005 (DISP_E_TYPEMISMATCH))

Discussion created by EduPro on Oct 10, 2019
Latest reply on Oct 11, 2019 by EduPro

Hi, developers!

I have some question about using late binding (PI SDK). I need to use late binding. I have no problem reading properties and its values of any PISDK object (such as PISDKVersion, PIPoint, PIValue) but when I tried to update pipoint value is shown error - Type mismatch (exception from HRESULT: 0x80020005 (DISP_E_TYPEMISMATCH)).

Method syntax:

void UpdateValue(object newValue, object TimeStamp, [PISDK.DataMergeConstants MergeType = PISDK.DataMergeConstants.dmReplaceDuplicates], [PISDKCommon.PIAsynchStatus asynchStatus = null])

Member PISDK._PIData

 

I tried to use code like this:

 

object[] args = new object[4];

args[0] = Value; // float

args[1] = DT; // DateTime

args[2] = 0;

args[3] = null;

oPIData.GetType().InvokeMember("UpdateValue", BindingFlags.InvokeMethod, null, oPIData, args); // error here

 

then code like this:

 

object[] args = new object[4];

args[0] = Value; // float

args[1] = DT; // DateTime

args[2] = 0;

args[3] = null;

ParameterModifier p = new ParameterModifier(4);

p[0] = true;

p[1] = true;

p[2] = true;

p[3] = true;

ParameterModifier[] mods = { p };

oPIData.GetType().InvokeMember("UpdateValue", BindingFlags.InvokeMethod, null, oPIData, args, mods, null, null); // error here

Does anybody know how to correctly pass parameters to UpdateValue method and write value to database?

Outcomes