Bonjour,
j'avais écrit sous VB6 un client OPC qui fonctionnait plutôt bien.
Devant y ajouter des fonctions, on m'a demander de le reprendre en VB.NET
Ce programme fait appel à une DLL (OPCDAAuto.DLL) fournie par la fondation OPC.
en programmation VB6,
1 2 3 4 5 6 7 8 9 10 11 12 13 14
|
Dim oServer As OPCAutomation.OPCServer
Dim oTagGroup As OPCAutomation.OPCGroup
Dim oTags As OPCAutomation.OPCItems
Dim sOpcTag(1) As String
Dim LTagErrors(1) As Long
Set oServer = New OPCServer
Set oTagGroup = oServer.OPCGroup
Set oTags = oTagGroup.OPCItems
sOpcTag(1) = "Item1"
oTags.Validate 1, sOpcTag(), LTagErrors() |
ce code fonctionne bien. je veux dire par là que la fonction OPCAutomation.OPCItems.Validate renvoie dans LTagErrors(1) une valeur non nulle si Item1 n'existe pas
Maintenant je passe en VB.NET
1 2 3 4 5 6 7 8 9 10 11 12 13 14
|
Dim oServer As OPCAutomation.OPCServer
Dim oTagGroup As OPCAutomation.OPCGroup
Dim oTags As OPCAutomation.OPCItems
Dim sOpcTag(1) As String
Dim LTagErrors(1) As Long
Set oServer = New OPCServer
Set oTagGroup = oServer.OPCGroup
Set oTags = oTagGroup.OPCItems
sOpcTag(1) = "Item1"
oTags.Validate (2, sOpcTag, LTagErrors) |
maintenat j'ai l'erreur suivante :
Impossible d'effectuer un cast d'un objet de type 'System.Int32[*]' en type 'System.Int32[]'
la definition de la fonction Validate est la suivante :
-avec VB6:
Sub Validate(NumItems As Long, ItemIDs() As String, Errors() As Long, [RequestedDataTypes], [AccessPaths])
-avec VB.NET
Sub Validate(NumItems As Integer, ByRef ItemIDs As Array, ByRef Errors As Array, Optional RequestedDataTypes As Object = Nothing, Optional AccessPaths As Object = Nothing)
j'ai beau tourner le truc dans tout les sens je ne trouve pas.
Merci de votre aide.
Partager