Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Interop / December 2003

Tip: Looking for answers? Try searching our database.

Use old Fortran dll in .Net

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
sara - 22 Dec 2003 16:18 GMT
I have one function I'd like to call in this old dll. I
believe I am calling it correctly, because of the errors I
am getting, but it is not working.

The funtion takes these arguments:

Inputs:

NOPRT - CHAR*1
L - Integer
MILGRD - Char*(*)
ISQR - Integer

Outputs:

XLAT - D. Prec.
XLON - D. Prec
IERROR - INTEGER

I have called the function as such:

DECLARE FUNCTION MilGridToLatLon Lib "c:\convert.dll"
Alias "#2" (ByVal NORPT as Char, ByVal L as Integer, ByVal
MILGRD as String, ByVal ISQR as Integer,  ByRef XLAT as
IntPtr, ByRef XLON as IntPtr, ByRef IError as IntPtr)

Then after the function I try to marshall the pointers to
a string.

I have never marshaled before, this is all new to me, but
from what I have read, this seems like the right approach.
Can someone please help??

Thank you!

You can respond at sara@nospam-ilovecode.com
Bart Jacobs - 22 Dec 2003 16:32 GMT
Sara,

Try the following:

Declare Function MilGridToLatLon
    Lib "c:\convert.dll"
    Alias "#2" (
        ByVal NORPT as Char,
        ByVal L as Integer,
        ByVal MILGRD as String,
        ByVal ISQR as Integer,
        ByRef XLAT as Double,
        ByRef XLON as Double,
        ByRef IError as Integer)

Greetings

Bart Jacobs
- 22 Dec 2003 17:43 GMT
Thanks for replying,

I had tried that initially, but when i looked at the
contents before I cll the function as well as after, they
remain the same, nothing was changed. That is why I went
the IntPtr route. But with that route I get a runtime
error:

PInvoke: Cannot return variants.
Bart Jacobs - 22 Dec 2003 18:20 GMT
Sara,

Try "Declare Sub" instead of "Declare Function".

Also, is there any additional information about the DLL entry point in
addition to the Fortran input and output variables? For example, a C
header file or documentation directed at C programmers, or some
documentation on interop with other languages in the Fortran compiler's
reference manual?

Good luck!

Bart Jacobs
Max - 23 Dec 2003 07:40 GMT
Any function in VB has a return value. If it's type is not specified, basic
assumes variant (Any).
Your Fortran function does not return variant.
What does it return?
Try adding "As System.Void" at the end of your function declaration in VB.

One more idea:

Declare Function MilGridToLatLon
Lib "c:\convert.dll"
Alias "#2" (
ByVal NORPT as Char,
ByVal L as Integer,
ByVal MILGRD as String,
ByVal ISQR as Integer,
ByRef XLAT as Double,
ByRef XLON as Double
) As Integer
> Thanks for replying,
>
[quoted text clipped - 5 lines]
>
> PInvoke: Cannot return variants.

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.