Bonjour, j'ai parcouru le Forum et n'ai rien trouvé qui fonctionne.J'essaye d'acceder a une DLL non managé et j'ai cette erreur :
<<Le type n'a pas pu être marshalé, car la longueur d'une instance de tableau incorporée ne correspond pas à la longueur déclarée dans la disposition.>>
EN VB6 :
Declare Function Lance Lib "USBLib" (ByVal hHandle As Integer, ByRef pTransfer As DATA_ACQUISITION) As Integer
Public Type DATA_ACQUISITION
Calibrage As Byte
Voie(3) As ACQUISITION_VOIE
Config As ACQUISITION_CONFIG
Trig As ACQUISITION_TRIG
End Type
EN VB.NET :
Declare Function Lance Lib "USBLib" (ByVal hHandle As Integer, <MarshalAsAttribute(UnmanagedType.Struct)> ByRef pTransfer As DATA_ACQUISITION) As Integer
<StructLayout(LayoutKind.Sequential)> Public Structure DATA_ACQUISITION
Dim Calibrage As Byte
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=12)> Dim Voie() As ACQUISITION_VOIE
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=6)> Dim Config As ACQUISITION_CONFIG
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=7)> Dim Trig As ACQUISITION_TRIG
'----------------------------------------------------------
Public Sub Initialize()
ReDim Voie(3)
End Sub
End Structure
Dans les structure en VB6 j'ai des byte et des long que j'ai transformé en byte et integer pour VB.NET. Visiblement ce serait la declaratation de tableau de structure (--Voie()--) qui poserai problème. Enfin je crois.
Je pensais avoir compris "en partie" la marshalisation mais alors là je suis perdu ... Si vous avez une idée
MisterMok