I have been given a fortran dll created by a coworker to use in my c# app. the dll was compiled as 32 bit dll and the function i desire has been exported. i confirmed the export using DUMPBIN /EXPORTS my.dll and the function i want to use is listed.
When I try to call the function i get an exception: BadImageFormatException - an attempt was made to load a program with an incorrect format.
My application has been compiled with VS 2010 as 32 bit but I am running on Windows 7 64 bit. Below is my c# code:
using System;
namespace FortranTest
{
class Program
{
static void Main(string[] args)
{
double p = (double)2500.0;
double t = (double)950.0;
short b = (short)1;
float h = FortranWrapper.ENTPT(ref p, ref t, ref b);
}
}
}
using System;
using System.Runtime.InteropServices;
namespace FortranTest
{
class FortranWrapper
{
[DllImport("My.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern float ENTPT(ref double Pa, ref double Tx, ref short b);
}
}
I did NOT install the Fortran development environment but the runtime libs located here:
I know very little about fortran but need help getting this working. its probably something stupid that i am doing but i cant find it.
Thanks in advance for any help!!
charlie