C# can't find an entry point in Fortran dll
MODULE MYVAR
REAL*8 LK
COMMON LK
END MODULE
SUBROUTINE SETLK(NEWLK)
!DEC$ ATTRIBUTES DLLEXPORT :: SETLK
USE MYVAR
REAL*8 NEWLK
LK = NEWLK
END
SUBROUTINE GETLK(LKOUT)
!DEC$ ATTRIBUTES DLLEXPORT :: GETLK
USE MYVAR
REAL*8, INTENT(OUT):: LKOUT
LKOUT = LK
END
Now i'm trying to call them in C#
[DllImport(@"MYDLL.dll", CharSet = CharSet.Ansi,
CallingConvention = CallingConvention.Cdecl,
EntryPoint="SETLK")]
public static extern void SETLK(ref double NEWLK);
[DllImport(@"MYDLL.dll", CharSet = CharSet.Ansi,
CallingConvention = CallingConvention.Cdecl,
EntryPoint="GETLK")]
public static extern void GETLK(out double LKOUT);
static void Main(string[] args)
{
double d1 = 1.234;
SETLK(ref d1);
double d2;
GETLK(out d2);
Console.WriteLine(d2.ToString());
}
I get EntryPointNotFoundException "Fail to find entry point 'SETLK' in 'MYDLL.dll'". What do i have to do to make it work?
ThanxThis thread suggests you need a .def file to declare the function exports (just as you used to in native Windows programming)
Look into your dll with a tool like PE explorer. It will tell you what exact functions are exported.
精彩评论