473,382 Members | 1,423 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Ccall to the DLL

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
Jul 21 '05 #1
1 1561
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?= <an*******@discussions.microsoft.com>
|Subject: Ccall to the DLL
|Date: Thu, 20 May 2004 03:36:03 -0700
|Lines: 132
|Message-ID: <FD**********************************@microsoft.co m>
|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
|

Jul 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Robert W. | last post by:
I have an About box where I've successfully implemented a custom paint event. The structure of it is simple: protected void PaintClient(Object sender, PaintEventArgs e) { // Assorted graphics...
1
by: Quique | last post by:
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...
8
by: toton | last post by:
Hi, I am facing problem some times, and not finding a suitable answer to solve it. I have a vector (or some other container, sometimes) of some class, named CC like vector<CCv, NOT vector<CC*; ...
6
by: Ryan Liu | last post by:
Hi, I have a form, with some user control in it, usually hung up when I call form.Show(). I debug to there, I found in Visual Studio 2003, the call stack is empty! And CPU is not busy at...
14
by: Megalo | last post by:
why not make "name mangling" of C++ standard so should be possible to call the classes and the functions of C++ from other C++ compiler thanks
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.