I am trying to call a fortran dll from c# code. But i get the following error message.An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B). Could any one please tell me where I am going wrong? The codes are given below.
Fortran code
C# Code
Fortran code
Code:
! lwing.f90 ! ! FUNCTIONS/SUBROUTINES exported from lwing.dll: ! lwing - subroutine ! ! Expose subroutine lwing to users of this DLL ! !DEC$ ATTRIBUTES DLLEXPORT::lwing ! Variables SUBROUTINE lwing(span,dfuse,lenw) !------------------------------------------------------------------- ! This subroutine calculates the wing length in cantilever position !Input arguments: span- wing span ! dfuse- Fuselage diameter !Output Arguments: lenw- Length of wing in cantilever position !------------------------------------------------------------------- IMPLICIT NONE REAL, INTENT(IN)::dfuse,span REAL, INTENT(OUT)::lenw lenw=(span-dfuse)/2; END SUBROUTINE lwing
C# Code
Code:
namespace ggg
{
public class Model
{
[DllImport("lwing.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Winapi)] /* Import from DLL, the C# compiler provides a rudimentry check of the signature */
public static extern void lwing(ref double span,ref double dfuse,ref double lenw);
static void Main()
{
double a = 1;
double b = 1;
double c = 1;
lwing(ref a,ref b,ref c);
}
}
}
Comment