Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

VB.Net calling Fortran function

IVV_I_
Beginner
410 Views

I'm having difficulties to translate the following fortan function interface to the corresponding vb.net pinvoke statement:

  recursive function MatMerge(iNum, haMatrices, faWeights ) result( pResult )
  !DIR$ ATTRIBUTES STDCALL, REFERENCE, NOMIXED_STR_LEN_ARG, ALIAS:'V3MatMerge'	::	MatMerge
  !DIR$ ATTRIBUTES VALUE  ::  iNum
  USE, INTRINSIC :: ISO_C_BINDING

  implicit none

  type(T_MATRIX), pointer ::  pResult
  
  integer(4)  ::  iNum
  integer(c_intptr_t), intent(in)  ::  haMatrices(iNum)
  real(4), intent(in)              ::  faWeights(iNum)
  
  ! ...

  end

The declaration I've tried so far looks like this.

<DllImport(dllfile, CallingConvention:=CallingConvention.StdCall, CharSet:=CharSet.Ansi)>
Friend Function V3MatMerge(ByVal numMatrices As Integer, _
                           <[In]()> hMatrix As IntPtr(), _
                           <[In]()> faWeights As Single()) As IntPtr
End Function

I'm getting "EntryPointNotFound" exceptions, though dumpbin clearly lists the function in the DLL that is loaded.

TIA

Felix Obermaier

0 Kudos
1 Reply
Steve_Lionel
Honored Contributor III
410 Views

VB will give this error if a dependent DLL is not found. Do you have Intel Fortran installed on the system where you're running the VB code? Are you running from inside Visual Studio or outside? Is the Fortran DLL a Debug or Release configuration?

In the examples I have seen, VB arrays have to be passed to fortran ByVal otherwise you get a SafeArray descriptor. There's examples of doing it either way in the compiler_f\MixedLanguage folder of the Intel Parallel Studio XE for Windows Samples Bundle.

0 Kudos
Reply