Exception calling Fortran dll function from C #

I have an existing VB6 program that calls a Fortran DLL with the following definition:

Declare Function START Lib "BackEndLib2.dll" Alias "_START@0" () As Integer

We are trying to port a VB6 application to C # (.net 4.0), and now this definition looks like this:

[DllImport("BackEndLib2.dll", EntryPoint = "_START@0")]
public static extern short START();

However, when I call the same function call in C #, it makes a dll call, it successfully returns to the managed code and throws an exception after a while.

I also tried the same dll call in VB.net with the same result:

Declare Function START Lib "BackEndLib2.dll" Alias "_START@0" () As Short

Any idea why the same function call throws an exception in .NET 4.0 but works successfully in vb6?

I assume that I damage the stack with the dll call, but I'm not sure. I tried many different types of parameters, but so far nothing has worked.

: WPF, Windows Forms, .

+3
2

[DllImport] VB6. , , VB6 , , . , , CPU, .

Debug + Windows+. ESP . , , . , , MDA. , Fortran, .

, . , SOE, , . ESP, .

+2

, FORTRAN, :

        INTEGER*4 FUNCTION START( )
CDEC$ATTRIBUTES STDCALL, DLLEXPORT :: START
C.....  BODY HERE
        ENDFUNCTION

, :

[DllImport(..., CallingConvention = CallingConvention.StdCall)]
public static extern int Start( );

, FORTRAN DLL? , STDCALL? , C.

0

Source: https://habr.com/ru/post/1780700/


All Articles