0

Call an older third party dll, passing parameters require an object, but the same parameter output an array, how to accomplish this? Thank you?

Array ItemValues = Array.CreateInstance(typeof(int), 1);
            Array ItemServerErrors = Array.CreateInstance(typeof(int), 1);

            Array ItemQuality = Array.CreateInstance(typeof(int), 1);
            Array ItemtimeStamp = Array.CreateInstance(typeof(DateTime), 1); 


            myGroup.SyncRead(1, 1, ref RandomMoneyHandler, ref ItemValues, out ItemServerErrors, out ItemQuality, out ItemtimeStamp);

But QualityObject and TimeStampObject indeed returns an array from VB example

 Dim ItemCount As Short = 1
    Dim ItemServerHandles(1) As Integer
    Dim ItemValues As Array
    Dim ItemServerErrors As Array
    Dim ItemQuality As Array
    Dim ItemTimeStamp As Array

    ItemServerHandles(1) = myItem.ServerHandle

    myGroup.SyncRead(OPCAutomation.OPCDataSource.OPCCache, ItemCount, ItemServerHandles, ItemValues, ItemServerErrors, ItemQuality, ItemTimeStamp)

enter image description here

What are the syntax for this function call in C#?

2

1 Answer 1

0

Its clear from image you shared

SyncRead() excepts ItemValues as out parameter , you are passing it as ref

Try changing your code from

 myGroup.SyncRead(1, 1, ref RandomMoneyHandler, ref ItemValues, out ItemServerErrors, out ItemQuality, out ItemtimeStamp);

to

 myGroup.SyncRead(1, 1, ref RandomMoneyHandler, out ItemValues, out ItemServerErrors, out ItemQuality, out ItemtimeStamp);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.