Problem with Schneider OPC and VB.NET 2005

A

Thread Starter

Andrej Mulej

Till now I made applications in VB6. Now I want to use Visual Studio 2005 (VB.NET). But I have problem to create groups.

The VB return:Unable to cast object of type 'SAOPCAutomation.OPCServerClass' to type 'SAOPCAutomation.IOPCGroups'.

Code:

Dim AnOPCServer As SAOPCAutomation.OPCServer
Dim ARealOPCServer As String
Dim ARealOPCNodeName As String
Dim AnOPCServerBrowser As SAOPCAutomation.OPCBrowser
Dim MyGroups As SAOPCAutomation.OPCGroups
Dim DefaultGroupUpdateRate As Long
Dim OneGroup As SAOPCAutomation.OPCGroup
Dim AnOPCItemCollection As SAOPCAutomation.OPCItems
Dim AnOPCItem As SAOPCAutomation.OPCItem
Dim AnOPCItemIDs(100) As String
Dim AnOPCItemServerHandles() As Long
Dim AnOPCItemServerErrors() As Long

AnOPCServer = New SAOPCAutomation.OPCServer
ARealOPCServer = "Schneider-Aut.OFS"
ARealOPCNodeName = "compaq1"
AnOPCServer.Connect(ARealOPCServer, ARealOPCNodeName)
MyGroups = AnOPCServer.OPCGroups ' error in this line

I have tested the Schneider OFS version 2.5 and the DEMO Version 3.2.

Please, help me!!! Where can I find any sample code for VB.NET and OPC. Best regardes and Best Wishes in 2006!

Andrej Mulej
 
F

Florent TONSON

OPC (DCOM) is not directly supported by dotnet (see OPCFoundation.org). If you want to deal with OPC and DotNet, 2 solutions:

-1- Be an OPC Member and get DotNet function from OPCFundation (too expensive solution).

-2- Buy a dotnet OPC client DLL.

We've bought MetaDynamics OPC ClientX and it's work fine.

Hope it will help you, sorry for my (poor) english.
 
Top