G
An unhandled exception of type 'System.InvalidCastException' occurred in WindowsApplication2.exe
Additional information: QueryInterface for interface OPCAutomation.IOPCGroups failed.
I'm running this code stops at line marked with ***
Imports OPCAutomation
Imports System.Runtime.InteropServices
Dim WithEvents AnOPCServer As OPCServer
Dim WithEvents ConnectedOPCServer As OPCServer
Dim ConnectedServerGroup As OPCGroup
Dim WithEvents ConnectedGroup As OPCGroup
Dim OPCItemCollection As OPCItems
Dim ItemCount As Long
Dim OPCItemIDs(10) As String
Dim ItemServerHandles() As Long
Dim ItemServerErrors() As Long
Dim ClientHandles(10) As Long
'Create a new OPC Server object
ConnectedOPCServer = New OPCServer
'Attempt to connect with the server (Local only in this example)
ConnectedOPCServer.Connect(Servername.Text, NodeName.Text)
'Prepare to add a group to the current OPC Server
' Get the group interface from the server object
*** ConnectedServerGroup = CType Marshal.CreateWrapperOfType(ConnectedOPCServer.OPCGroups, GetType(OPCGroupsClass)), OPCGroupsClass)
'i have allso tryed this way to connect the group interface!
ConnectedServerGroup = ConnectedOPCServer.OPCGroups()
Additional information: QueryInterface for interface OPCAutomation.IOPCGroups failed.
I'm running this code stops at line marked with ***
Imports OPCAutomation
Imports System.Runtime.InteropServices
Dim WithEvents AnOPCServer As OPCServer
Dim WithEvents ConnectedOPCServer As OPCServer
Dim ConnectedServerGroup As OPCGroup
Dim WithEvents ConnectedGroup As OPCGroup
Dim OPCItemCollection As OPCItems
Dim ItemCount As Long
Dim OPCItemIDs(10) As String
Dim ItemServerHandles() As Long
Dim ItemServerErrors() As Long
Dim ClientHandles(10) As Long
'Create a new OPC Server object
ConnectedOPCServer = New OPCServer
'Attempt to connect with the server (Local only in this example)
ConnectedOPCServer.Connect(Servername.Text, NodeName.Text)
'Prepare to add a group to the current OPC Server
' Get the group interface from the server object
*** ConnectedServerGroup = CType Marshal.CreateWrapperOfType(ConnectedOPCServer.OPCGroups, GetType(OPCGroupsClass)), OPCGroupsClass)
'i have allso tryed this way to connect the group interface!
ConnectedServerGroup = ConnectedOPCServer.OPCGroups()