J
James Radke
Hello,
We are currently using a user DLL that when working in VB 6.0 has a user
defined type as a parameter.
Now we are trying to use the same DLL from a vb.net application and are
having some problems getting it to work and we don't know why. Basically
the function is accepting the parameters, and then returning an error and
never performing the update.
Below you will find both the VB6 dll function and user defined type
definition, followed by the VB.NET (2003 version) dll function and structure
definition that we are using. Unfortunately I do not have the source code to
the DLL, so I don't know how the fields are defined in there.
Can someone tell me what may be defined incorrectly, or how I can figure out
why the call is not working? Also, I have tried every type of
UnmanagedType.<string type> in the definitions within the structure (i.e.
LPSTR, etc)
One of these should work, shouldn't they? What else could be happening?
Any help would be appreciated!
Jim
==== Begin VB 6 dll function and type definition ===
Declare Function AddSalesOrderLineItem Lib "MAXORDR2.DLL" (ByVal OH As Long,
Soedet As SOEDetItem) As Integer
Type SODetail
ORDNUM28 As String * 6 ' String
LINNUM28 As String * 2 ' String
DELNUM28 As String * 2 ' String
STATUS28 As String * 1 ' String
CUSTID28 As String * 7 ' String
PRTNUM28 As String * 15 ' String
EDILIN28 As String * 6 ' String
TAXABL28 As String * 1 ' String
GLXREF28 As String * 32 ' String
CURDUE28 As Long ' Btrieve Date
FILL0128 As String * 2 ' String
ORGDUE28 As Long ' Btrieve Date
FILL0228 As String * 2 ' String
CUSDUE28 As Long ' Btrieve Date
FILL0328 As String * 2 ' String
SHPDTE28 As Long ' Btrieve Date
FILL0428 As String * 2 ' String
SLSUOM28 As String * 2 ' String
REFRNC28 As String * 25 ' String
PRICE28 As Double ' IEEE Float
ORGQTY28 As Double ' IEEE Float
CURQTY28 As Double ' IEEE Float
BCKQTY28 As Double ' IEEE Float
SHPQTY28 As Double ' IEEE Float
CURSHP28 As Double ' IEEE Float
DUEQTY28 As Double ' IEEE Float
INVQTY28 As Double ' IEEE Float
DISC28 As Single ' IEEE Float
STYPE28 As String * 2 ' String
PRNT28 As String * 1 ' String
AKPRNT28 As String * 1 ' String
STK28 As String * 8 ' String
COCFLG28 As String * 3 ' String
FORCUR28 As Double ' IEEE Float
HSTAT28 As String * 1 ' String
SLSREP28 As String * 7 ' String
COMMIS28 As Single ' IEEE Float
DRPSHP28 As String * 10 ' String
QUMQTY28 As Single ' IEEE Float
TAXCDE128 As String * 7 ' String
TAX128 As Double ' IEEE Float
TAXCDE228 As String * 7 ' String
TAX228 As Double ' IEEE Float
TAXCDE328 As String * 7 ' String
TAX328 As Double ' IEEE Float
MCOMP28 As String * 3 ' String
MSITE28 As String * 3 ' String
UDFKEY28 As String * 15 ' String
UDFREF28 As String * 25 ' String
DEXPFLG28 As String * 1 ' String (adChar)
FILLER28 As String * 24 ' String
End Type
====== END VB 6 Type definition
====== Begin VB.NET DLL function and Structure Definition =======
Declare Function AddSalesOrderLineItem Lib "MAXORDR2.DLL" (ByVal OH As
Int32, ByRef Soedet As SOEDetItem) As Short
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Ansi)> _
Public Structure SOEDetItem
<MarshalAs(UnmanagedType.LPStr, SizeConst:=6)> Public ORDNUM As
String
<MarshalAs(UnmanagedType.LPStr, SizeConst:=2)> Public LINNUM As
String
<MarshalAs(UnmanagedType.LPStr, SizeConst:=2)> Public DelNum As
String
<MarshalAs(UnmanagedType.LPStr, SizeConst:=1)> Public STATUS As
String
<MarshalAs(UnmanagedType.LPStr, SizeConst:=7)> Public CUSTID As
String
<MarshalAs(UnmanagedType.LPStr, SizeConst:=15)> Public PRTNUM As
String
<MarshalAs(UnmanagedType.LPStr, SizeConst:=6)> Public EDILIN As
String
<MarshalAs(UnmanagedType.LPStr, SizeConst:=1)> Public TAXABL As
String
<MarshalAs(UnmanagedType.LPStr, SizeConst:=32)> Public GLXREF As
String
Public CURDUE As Int32
<MarshalAs(UnmanagedType.LPStr, SizeConst:=2)> Public FILL01 As
String
Public ORGDUE As Int32
<MarshalAs(UnmanagedType.LPStr, SizeConst:=2)> Public FILL02 As
String
Public CUSDUE As Int32
<MarshalAs(UnmanagedType.LPStr, SizeConst:=2)> Public FILL03 As
String
Public SHPDTE As Int32
<MarshalAs(UnmanagedType.LPStr, SizeConst:=2)> Public FILL04 As
String
<MarshalAs(UnmanagedType.LPStr, SizeConst:=2)> Public SLSUOM As
String
<MarshalAs(UnmanagedType.LPStr, SizeConst:=25)> Public REFRNC As
String
Public PRICE As Double
Public ORGQTY As Double
Public CURQTY As Double
Public BCKQTY As Double
Public SHPQTY As Double
Public CURSHP As Double
Public DUEQTY As Double
Public INVQTY As Double
Public DISC As Single
<MarshalAs(UnmanagedType.LPStr, SizeConst:=2)> Public STYPE As
String
<MarshalAs(UnmanagedType.LPStr, SizeConst:=1)> Public PRNT As String
<MarshalAs(UnmanagedType.LPStr, SizeConst:=1)> Public AKPRNT As
String
<MarshalAs(UnmanagedType.LPStr, SizeConst:=8)> Public STK As String
<MarshalAs(UnmanagedType.LPStr, SizeConst:=3)> Public COCFLG As
String
Public FORCUR As Double
<MarshalAs(UnmanagedType.LPStr, SizeConst:=1)> Public HSTAT As
String
<MarshalAs(UnmanagedType.LPStr, SizeConst:=7)> Public SLSREP As
String
Public COMMIS As Single
<MarshalAs(UnmanagedType.LPStr, SizeConst:=10)> Public DRPSHP As
String
Public QUMQTY As Single
<MarshalAs(UnmanagedType.LPStr, SizeConst:=7)> Public TAXCDE1 As
String
Public TAX1 As Double '# TAX AMOUNT 1
<MarshalAs(UnmanagedType.LPStr, SizeConst:=7)> Public TAXCDE2 As
String
Public TAX2 As Double
<MarshalAs(UnmanagedType.LPStr, SizeConst:=7)> Public TAXCDE3 As
String
Public TAX3 As Double '$ TAX AMOUNT 3
<MarshalAs(UnmanagedType.LPStr, SizeConst:=3)> Public MCOMP As
String
<MarshalAs(UnmanagedType.LPStr, SizeConst:=3)> Public MSITE As
String
<MarshalAs(UnmanagedType.LPStr, SizeConst:=15)> Public UDFKEY As
String
<MarshalAs(UnmanagedType.LPStr, SizeConst:=25)> Public UDFREF As
String
<MarshalAs(UnmanagedType.LPStr, SizeConst:=1)> Public DEXPFLG As
String
<MarshalAs(UnmanagedType.LPStr, SizeConst:=25)> Public FILLER As
String
End Structure
==== End vb.net struct definition ======
We are currently using a user DLL that when working in VB 6.0 has a user
defined type as a parameter.
Now we are trying to use the same DLL from a vb.net application and are
having some problems getting it to work and we don't know why. Basically
the function is accepting the parameters, and then returning an error and
never performing the update.
Below you will find both the VB6 dll function and user defined type
definition, followed by the VB.NET (2003 version) dll function and structure
definition that we are using. Unfortunately I do not have the source code to
the DLL, so I don't know how the fields are defined in there.
Can someone tell me what may be defined incorrectly, or how I can figure out
why the call is not working? Also, I have tried every type of
UnmanagedType.<string type> in the definitions within the structure (i.e.
LPSTR, etc)
One of these should work, shouldn't they? What else could be happening?
Any help would be appreciated!
Jim
==== Begin VB 6 dll function and type definition ===
Declare Function AddSalesOrderLineItem Lib "MAXORDR2.DLL" (ByVal OH As Long,
Soedet As SOEDetItem) As Integer
Type SODetail
ORDNUM28 As String * 6 ' String
LINNUM28 As String * 2 ' String
DELNUM28 As String * 2 ' String
STATUS28 As String * 1 ' String
CUSTID28 As String * 7 ' String
PRTNUM28 As String * 15 ' String
EDILIN28 As String * 6 ' String
TAXABL28 As String * 1 ' String
GLXREF28 As String * 32 ' String
CURDUE28 As Long ' Btrieve Date
FILL0128 As String * 2 ' String
ORGDUE28 As Long ' Btrieve Date
FILL0228 As String * 2 ' String
CUSDUE28 As Long ' Btrieve Date
FILL0328 As String * 2 ' String
SHPDTE28 As Long ' Btrieve Date
FILL0428 As String * 2 ' String
SLSUOM28 As String * 2 ' String
REFRNC28 As String * 25 ' String
PRICE28 As Double ' IEEE Float
ORGQTY28 As Double ' IEEE Float
CURQTY28 As Double ' IEEE Float
BCKQTY28 As Double ' IEEE Float
SHPQTY28 As Double ' IEEE Float
CURSHP28 As Double ' IEEE Float
DUEQTY28 As Double ' IEEE Float
INVQTY28 As Double ' IEEE Float
DISC28 As Single ' IEEE Float
STYPE28 As String * 2 ' String
PRNT28 As String * 1 ' String
AKPRNT28 As String * 1 ' String
STK28 As String * 8 ' String
COCFLG28 As String * 3 ' String
FORCUR28 As Double ' IEEE Float
HSTAT28 As String * 1 ' String
SLSREP28 As String * 7 ' String
COMMIS28 As Single ' IEEE Float
DRPSHP28 As String * 10 ' String
QUMQTY28 As Single ' IEEE Float
TAXCDE128 As String * 7 ' String
TAX128 As Double ' IEEE Float
TAXCDE228 As String * 7 ' String
TAX228 As Double ' IEEE Float
TAXCDE328 As String * 7 ' String
TAX328 As Double ' IEEE Float
MCOMP28 As String * 3 ' String
MSITE28 As String * 3 ' String
UDFKEY28 As String * 15 ' String
UDFREF28 As String * 25 ' String
DEXPFLG28 As String * 1 ' String (adChar)
FILLER28 As String * 24 ' String
End Type
====== END VB 6 Type definition
====== Begin VB.NET DLL function and Structure Definition =======
Declare Function AddSalesOrderLineItem Lib "MAXORDR2.DLL" (ByVal OH As
Int32, ByRef Soedet As SOEDetItem) As Short
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Ansi)> _
Public Structure SOEDetItem
<MarshalAs(UnmanagedType.LPStr, SizeConst:=6)> Public ORDNUM As
String
<MarshalAs(UnmanagedType.LPStr, SizeConst:=2)> Public LINNUM As
String
<MarshalAs(UnmanagedType.LPStr, SizeConst:=2)> Public DelNum As
String
<MarshalAs(UnmanagedType.LPStr, SizeConst:=1)> Public STATUS As
String
<MarshalAs(UnmanagedType.LPStr, SizeConst:=7)> Public CUSTID As
String
<MarshalAs(UnmanagedType.LPStr, SizeConst:=15)> Public PRTNUM As
String
<MarshalAs(UnmanagedType.LPStr, SizeConst:=6)> Public EDILIN As
String
<MarshalAs(UnmanagedType.LPStr, SizeConst:=1)> Public TAXABL As
String
<MarshalAs(UnmanagedType.LPStr, SizeConst:=32)> Public GLXREF As
String
Public CURDUE As Int32
<MarshalAs(UnmanagedType.LPStr, SizeConst:=2)> Public FILL01 As
String
Public ORGDUE As Int32
<MarshalAs(UnmanagedType.LPStr, SizeConst:=2)> Public FILL02 As
String
Public CUSDUE As Int32
<MarshalAs(UnmanagedType.LPStr, SizeConst:=2)> Public FILL03 As
String
Public SHPDTE As Int32
<MarshalAs(UnmanagedType.LPStr, SizeConst:=2)> Public FILL04 As
String
<MarshalAs(UnmanagedType.LPStr, SizeConst:=2)> Public SLSUOM As
String
<MarshalAs(UnmanagedType.LPStr, SizeConst:=25)> Public REFRNC As
String
Public PRICE As Double
Public ORGQTY As Double
Public CURQTY As Double
Public BCKQTY As Double
Public SHPQTY As Double
Public CURSHP As Double
Public DUEQTY As Double
Public INVQTY As Double
Public DISC As Single
<MarshalAs(UnmanagedType.LPStr, SizeConst:=2)> Public STYPE As
String
<MarshalAs(UnmanagedType.LPStr, SizeConst:=1)> Public PRNT As String
<MarshalAs(UnmanagedType.LPStr, SizeConst:=1)> Public AKPRNT As
String
<MarshalAs(UnmanagedType.LPStr, SizeConst:=8)> Public STK As String
<MarshalAs(UnmanagedType.LPStr, SizeConst:=3)> Public COCFLG As
String
Public FORCUR As Double
<MarshalAs(UnmanagedType.LPStr, SizeConst:=1)> Public HSTAT As
String
<MarshalAs(UnmanagedType.LPStr, SizeConst:=7)> Public SLSREP As
String
Public COMMIS As Single
<MarshalAs(UnmanagedType.LPStr, SizeConst:=10)> Public DRPSHP As
String
Public QUMQTY As Single
<MarshalAs(UnmanagedType.LPStr, SizeConst:=7)> Public TAXCDE1 As
String
Public TAX1 As Double '# TAX AMOUNT 1
<MarshalAs(UnmanagedType.LPStr, SizeConst:=7)> Public TAXCDE2 As
String
Public TAX2 As Double
<MarshalAs(UnmanagedType.LPStr, SizeConst:=7)> Public TAXCDE3 As
String
Public TAX3 As Double '$ TAX AMOUNT 3
<MarshalAs(UnmanagedType.LPStr, SizeConst:=3)> Public MCOMP As
String
<MarshalAs(UnmanagedType.LPStr, SizeConst:=3)> Public MSITE As
String
<MarshalAs(UnmanagedType.LPStr, SizeConst:=15)> Public UDFKEY As
String
<MarshalAs(UnmanagedType.LPStr, SizeConst:=25)> Public UDFREF As
String
<MarshalAs(UnmanagedType.LPStr, SizeConst:=1)> Public DEXPFLG As
String
<MarshalAs(UnmanagedType.LPStr, SizeConst:=25)> Public FILLER As
String
End Structure
==== End vb.net struct definition ======