Ccall to the DLL

G

Guest

I have migrated a software in Visual Basic 6.0 to Visual Basic .NET 200

I have solved the errors from compilation (AddressOf, ....) but when th
program is executed in the call to the DLL (loadnlp) I obtain an error. I
says the obj argument is not valid
Debuging I have checked the data used for the call to the DLL through Visua
Basil 6.0 and Visual Basic .Net are the same
I have tried everything, but I get the error again and again. Does anybod
know what can be the problem?

Thanks very muc

Regard


'Code in Visual Basic 6.

Declare Function loadnlp Lib "libreria.dll" (ByVal name As String, ByVal numcols As Long, ByVal numrows As Long, ByVal objsen As Long, obj() As Double, rhs() As Double, sense() As Byte, matbeg() As Long, matcnt() As Long, matind() As Long, matval() As Double, var() As Double, lb() As Double, ub() As Double, rngval() As Double, ByVal nzspace As Long, ByVal funceval As Long, ByVal jacobian As Long) As Lon

Public Sub VisualBasic60 (
Dim nNumVar As Intege
Dim nNumRest As Integer
Dim objval As Doubl
Dim ret,lp,nlstat As Lon
Dim obj() As Doubl
Dim rhs() As Doubl
Dim matval() As Doubl
Dim lb() As Doubl
Dim ub() As Doubl
Dim x() As Doubl
Dim piout() As Doubl
Dim slack() As Doubl
Dim dj() As Doubl
Dim sense() As Byt
Dim ctype() As Byt
Dim NullL(0) As Lon
Dim NullD(0) As Doubl
Dim NullB(0) As Byt

nNumVar =
ReDim obj(nNumVar - 1
ReDim lb(nNumVar - 1
ReDim ub(nNumVar - 1
ReDim ctype(nNumVar - 1
ReDim x(nNumVar - 1
ReDim dj(nNumVar - 1

NullL(0) = -
NullD(0) = -
NullB(0) =
nNumRest =
ReDim rhs(nNumRest - 1)
ReDim sense(nNumRest - 1
ReDim matval(nNumVar * nNumRest - 1
ReDim piout(nNumRest - 1
ReDim slack(nNumRest - 1
rhs(0) =
rhs(1) =
sense(0) = Asc("E"
sense(1) = Asc("E"
For nInd = 0 To (nNumVar) -
ctype(nInd) = Asc("C"
lb(nInd) =
ub(nInd) =
x(nInd) = 1 / (nNumVar
Nex
lp = loadnlp("123456", nNumVar, nNumRest, -1, obj, rhs, sense, NullL, NullL, NullL, matval, x, lb, ub, NullD, nNumVar * nNumRest, AddressOf metOptimo, 0

end su


---------------------------

'Code in Visula Basic .NE

Delegate Sub SubClassProcDelegate(
Declare Function loadnlp Lib "libreria.dll" (ByVal probname As String, ByVal numcols As Integer, ByVal numrows As Integer, ByVal objsen As Integer, ByRef DatoObj() As Double, ByRef rhs() As Double, ByRef sense() As Byte, ByRef matbeg() As Integer, ByRef matcnt() As Integer, ByRef matind() As Integer, ByRef matval() As Double, ByRef var() As Double, ByRef lb() As Double, ByRef ub() As Double, ByRef rngval() As Double, ByVal nzspace As Integer, ByVal funceval As SubClassProcDelegate, ByVal jacobian As Integer) As Intege

Sub VisualBasic_NET (
Dim objval As Doubl
Dim ret, lp, nlstat As Intege
Dim obj() As Doubl
Dim rhs() As Doubl
Dim matval() As Doubl
Dim lb() As Doubl
Dim ub() As Doubl
Dim x() As Doubl
Dim piout() As Doubl
Dim slack() As Doubl
Dim dj() As Doubl
Dim sense() As Byt
'UPGRADE_NOTE: ctype se actualizó a ctype_Renamed. Haga clic aquí para obtener más información: 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup1061"
Dim ctype_Renamed() As Byt
Dim NullL(0) As Intege
Dim NullD(0) As Doubl
Dim NullB(0) As Byt

nNumVar =
ReDim obj(nNumVar - 1
ReDim lb(nNumVar - 1
ReDim ub(nNumVar - 1
ReDim ctype(nNumVar - 1
ReDim x(nNumVar - 1
ReDim dj(nNumVar - 1

NullL(0) = -
NullD(0) = -
NullB(0) =
nNumRest =
ReDim rhs(nNumRest - 1)
ReDim sense(nNumRest - 1
ReDim matval(nNumVar * nNumRest - 1
ReDim piout(nNumRest - 1
ReDim slack(nNumRest - 1
rhs(0) =
rhs(1) =
sense(0) = Asc("E"
sense(1) = Asc("E"
For nInd = 0 To (nNumVar) -
ctype(nInd) = Asc("C"
lb(nInd) =
ub(nInd) =
x(nInd) = 1 / (nNumVar
Nex
lp = loadnlp("123456", nNumVar, nNumRest, -1, obj, rhs, sense, NullL, NullL, NullL, matval, x, lb, ub, NullD, nNumVar * nNumRest, AddressOf metOptimo, 0
end sub
 
V

Victor Urnyshev [MSFT]

Hello,

I am not sure if I understand correctly the type of problem you get. Could
you provide the type of the exception you get and full message text?
Also, the signature of the function loadnlp will be very useful.
This might be parameter marshalling problem, but this also might be an
error generated by the DLL. In FAQ the developer of the DLL recommend to
switch on error messages with the command:

setintparam(0, PARAM_ARGCK,1)

The DLL should show message box with the error description in this case.
Hope this helps,

--
Victor Urnyshev [MSFT]
This post is "AS IS" with no warranties, and confers no rights.

--------------------
|Thread-Topic: Ccall to the DLL
|thread-index: AcQ+Vj/uOQOZgCZWQUK5YmeI3IAmTQ==
|X-WN-Post: microsoft.public.dotnet.general
|From: =?Utf-8?B?UXVpcXVl?= <[email protected]>
|Subject: Ccall to the DLL
|Date: Thu, 20 May 2004 03:36:03 -0700
|Lines: 132
|Message-ID: <[email protected]>
|MIME-Version: 1.0
|Content-Type: text/plain;
| charset="Utf-8"
|Content-Transfer-Encoding: 8bit
|X-Newsreader: Microsoft CDO for Windows 2000
|Content-Class: urn:content-classes:message
|Importance: normal
|Priority: normal
|X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
|Newsgroups: microsoft.public.dotnet.general
|Path: cpmsftngxa10.phx.gbl
|Xref: cpmsftngxa10.phx.gbl microsoft.public.dotnet.general:134710
|NNTP-Posting-Host: tk2msftcmty1.phx.gbl 10.40.1.180
|X-Tomcat-NG: microsoft.public.dotnet.general
|
| I have migrated a software in Visual Basic 6.0 to Visual Basic .NET 2003

I have solved the errors from compilation (AddressOf, ....) but when the
program is executed in the call to the DLL (loadnlp) I obtain an error. It
says the obj argument is not valid.
Debuging I have checked the data used for the call to the DLL through Visual
Basil 6.0 and Visual Basic .Net are the same.
I have tried everything, but I get the error again and again. Does anybody
know what can be the problem??

Thanks very much

Regards



'Code in Visual Basic 6.0

Declare Function loadnlp Lib "libreria.dll" (ByVal name As String, ByVal
numcols As Long, ByVal numrows As Long, ByVal objsen As Long, obj() As
Double, rhs() As Double, sense() As Byte, matbeg() As Long, matcnt() As
Long, matind() As Long, matval() As Double, var() As Double, lb() As
Double, ub() As Double, rngval() As Double, ByVal nzspace As Long, ByVal
funceval As Long, ByVal jacobian As Long) As Long

Public Sub VisualBasic60 ()
Dim nNumVar As Integer
Dim nNumRest As Integer
Dim objval As Double
Dim ret,lp,nlstat As Long
Dim obj() As Double
Dim rhs() As Double
Dim matval() As Double
Dim lb() As Double
Dim ub() As Double
Dim x() As Double
Dim piout() As Double
Dim slack() As Double
Dim dj() As Double
Dim sense() As Byte
Dim ctype() As Byte
Dim NullL(0) As Long
Dim NullD(0) As Double
Dim NullB(0) As Byte


nNumVar =6
ReDim obj(nNumVar - 1)
ReDim lb(nNumVar - 1)
ReDim ub(nNumVar - 1)
ReDim ctype(nNumVar - 1)
ReDim x(nNumVar - 1)
ReDim dj(nNumVar - 1)

NullL(0) = -1
NullD(0) = -1
NullB(0) = 0
nNumRest = 2
ReDim rhs(nNumRest - 1)
ReDim sense(nNumRest - 1)
ReDim matval(nNumVar * nNumRest - 1)
ReDim piout(nNumRest - 1)
ReDim slack(nNumRest - 1)
rhs(0) = 0
rhs(1) = 0
sense(0) = Asc("E")
sense(1) = Asc("E")
For nInd = 0 To (nNumVar) - 1
ctype(nInd) = Asc("C")
lb(nInd) = 0
ub(nInd) = 1
x(nInd) = 1 / (nNumVar)
Next
lp = loadnlp("123456", nNumVar, nNumRest, -1, obj, rhs, sense, NullL,
NullL, NullL, matval, x, lb, ub, NullD, nNumVar * nNumRest, AddressOf
metOptimo, 0)

end sub



----------------------------


'Code in Visula Basic .NET

Delegate Sub SubClassProcDelegate()
Declare Function loadnlp Lib "libreria.dll" (ByVal probname As String,
ByVal numcols As Integer, ByVal numrows As Integer, ByVal objsen As
Integer, ByRef DatoObj() As Double, ByRef rhs() As Double, ByRef sense() As
Byte, ByRef matbeg() As Integer, ByRef matcnt() As Integer, ByRef matind()
As Integer, ByRef matval() As Double, ByRef var() As Double, ByRef lb() As
Double, ByRef ub() As Double, ByRef rngval() As Double, ByVal nzspace As
Integer, ByVal funceval As SubClassProcDelegate, ByVal jacobian As Integer)
As Integer

Sub VisualBasic_NET ()
Dim objval As Double
Dim ret, lp, nlstat As Integer
Dim obj() As Double
Dim rhs() As Double
Dim matval() As Double
Dim lb() As Double
Dim ub() As Double
Dim x() As Double
Dim piout() As Double
Dim slack() As Double
Dim dj() As Double
Dim sense() As Byte
'UPGRADE_NOTE: ctype se actualizó a ctype_Renamed. Haga clic aquí para
obtener más información:
'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup1061"'
Dim ctype_Renamed() As Byte
Dim NullL(0) As Integer
Dim NullD(0) As Double
Dim NullB(0) As Byte

nNumVar =6
ReDim obj(nNumVar - 1)
ReDim lb(nNumVar - 1)
ReDim ub(nNumVar - 1)
ReDim ctype(nNumVar - 1)
ReDim x(nNumVar - 1)
ReDim dj(nNumVar - 1)

NullL(0) = -1
NullD(0) = -1
NullB(0) = 0
nNumRest = 2
ReDim rhs(nNumRest - 1)
ReDim sense(nNumRest - 1)
ReDim matval(nNumVar * nNumRest - 1)
ReDim piout(nNumRest - 1)
ReDim slack(nNumRest - 1)
rhs(0) = 0
rhs(1) = 0
sense(0) = Asc("E")
sense(1) = Asc("E")
For nInd = 0 To (nNumVar) - 1
ctype(nInd) = Asc("C")
lb(nInd) = 0
ub(nInd) = 1
x(nInd) = 1 / (nNumVar)
Next
lp = loadnlp("123456", nNumVar, nNumRest, -1, obj, rhs, sense, NullL,
NullL, NullL, matval, x, lb, ub, NullD, nNumVar * nNumRest, AddressOf
metOptimo, 0)
end sub


|
 

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