PIEE-User

Unable to cast object of type 'OPCHDAAutomation.OPCHDAServerClass' to type 'OPCHDAAutomation.IOPCHDAItems'.

Discussion created by PIEE-User on Aug 5, 2010
Latest reply on Aug 11, 2010 by spilon

I have the following test code

Dim opcServer As New OPCHDAAutomation.OPCHDAServerClass
Dim opcItem As OPCHDAItem
Dim opcValues As OPCHDAHistory
Dim opcValue As OPCHDAValue
Dim varStart, varEnd As Object

opcServer.Connect("OSI.HDA.1")

***opcItem = opcServer.OPCHDAItems.AddItem("\\localhost\sinusoid", 1)
varStart = "NOW-1D"
varEnd = "NOW"
opcValues = opcItem.ReadRaw(varStart, varEnd)

For Each opcValue In opcValues
    System.Diagnostics.Debug.Print(opcValue.DataValue)
Next

The error

Unable to cast object of type 'OPCHDAAutomation.OPCHDAServerClass' to type 'OPCHDAAutomation.IOPCHDAItems'.
   at OPCHDAAutomation.OPCHDAServerClass.get_OPCHDAItems()

 

happens at line marked with asterix (or anywhere I try to access property OPCHDAItems.

 

Please advise

 

Thanks in advance for explaining error / supplying solution

Outcomes