Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Calling Fortran DLL from VB.Net Program

Hi Everyone,

I need help with the following, I appreciate if someone can help.

 

I have problem with calling a Fortran DLL from VB.net Program. The VB program provide the GUI while the Fortran DLL does the calculations.

 

The Fortran DLL opens and reads from data files supplied by the VB program. however, DLL program displays a message that says it can not open the file.

 

this is VB declaration of the DLL:

 

DeclareSub WIDTH_SUB Lib"C:\ALI\Namoi_TM\Data\Test\WIDTH_SUB.DLL" (ByVal Rating AsString, ByVal Rating_Len AsInteger, _

ByVal Height AsString, ByVal Height_Len AsInteger, _

ByVal Output AsString, ByVal Output_Len AsInteger)

 

and here the call statement in the VB program

 

Call WIDTH_SUB(Rating, Len(Rating), height, Len(height), output, Len(output))

 

This is where fortran DLL can't pass

SUBROUTINE WIDTH_SUB(RFILE,GFILE,OUTPUT)

IMPLICIT NONE

DLL_EXPORT WIDTH_SUB

CHARACTER(len=*),INTENT(IN)::gfile,rfile,OUTPUT

 

 

OPEN(UNIT=100,FILE=rfile,STATUS='old',iostat=ierr)

if(ierr.ne.0)then

write(*,20) trim(rfile)

20 format('Cannot open file ',a,' for input.')

WRITE(*,*)'ierr= ',ierr

go to 9990

end if

 

 

the ierr value is 155

 

 

and VB error message is "AcccessViolationException was unhandled: Attempted to read or write protected memory."

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...