Kepware Knowledge Base: Solution

Unable to Read a Multi-Dimensional Array from an OPC Server in VB.Net

Problem:This issue only applies to ClientAce projects written in VB.Net.

In ClientAce V1.0, a server item returned a two-dimensional array of data, but the item's Value Variable cannot be parsed.

In ClientAce V3.5, a server item returned a two-dimensional array of data, but the item's Value Variable is not in the correct array format.

In ClientAce V4.0, a server item returned a two-dimensional array of data, but the item's Value Variable is not in the correct array format.

Possible Cause:The issue results from the way that VB.Net sees the SafeArray being passed from the unmanaged communication code layer to the .Net layer. Projects written with C# will not have problems.

Solution:For the purpose of this explanation, the example array from the server will be a 2x5 array configured with the the following values:

0

1

2

3

4

5

6

7

8

9

1. For projects written against ClientAce V1.0, the array is unrecognizable. The best solution for users developing with this version is to upgrade to ClientAce V3.5 or V4.0.2. In ClientAce V3.5 projects, the row and column indices are reversed to be 5x2, with the values appearing as follows:

0

1

2

3

4

5

6

7

8

9

3. In ClientAce V4.0 projects, the array is again reversed but the element values are presented as follows:

0

5

1

6

2

7

3

8

4

9

Note: As long as developers are aware of the Microsoft limitations, the array data can be processed.