Problem with VB6 Types as Marshelled Structures in VB.Net to 3rd Party DLL

J

John Ye

Hello Folks!

I have a vendor that has supplied me with a VB6 Module and DLL
(and it works in VB6) that I would really like to migrate to VB.Net. I
have used the Upgrade Wizard in VS.Net but it is not taking this all the
way. I have made several modifications to address the Marshalling that
is referenced but I keep getting an error "Unhandled Exception - The
parameter is incorrect." when I pass the new structure to a Sub
declared in the DLL.

Any assistance to resolve whatever "Marshalling" that is
required to make this work would be greatly appreciated.

--- VB6 Module Code
-------------------------------------------------------
Option Explicit

Type UserType1
bytB1 As Byte
strS1 As String
intI1 As Integer
bytB2 As Byte
strS2 As String
intI2 As Integer
End Type

Type UserType2
bytB3 As Byte
intI3 As Integer
typT1(8) As UserType1
End Type

Public Declare Sub MySub Lib "ThirdParty.DLL" (ByRef MyVariable As
UserType2)
-------------------------------------------------------------------------
--

--- VB.Net Wizard Translation
---------------------------------------------
Option Strict Off
Option Explicit On

Module TransTest

Structure UserType1
Dim bytB1 As Byte
Dim strS1 As String
Dim intI1 As Short
Dim bytB2 As Byte
Dim strS2 As String
Dim intI2 As Short
End Structure

Structure UserType2
Dim bytB3 As Byte
Dim intI3 As Short
<VBFixedArray(8)> Dim typT1() As UserType1

Public Sub Initialize()
ReDim typT1(8)
End Sub
End Structure

Public Declare Sub MySub Lib "ThirdParty.DLL" (ByRef MyVariable As
UserType2)
End Module
-------------------------------------------------------------------------
--

Thank you for your time and thanks in advance for any help you
may provide.

Best Regards
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top