Quantcast
Channel: Intel® Software - Intel® Visual Fortran Compiler for Windows*
Viewing all articles
Browse latest Browse all 5691

C# calling fortran function error

$
0
0

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: 

http://software.intel.com/en-us/articles/redistributable-libraries-for-the-intel-c-and-visual-fortran-composer-xe-for-windows.

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


Viewing all articles
Browse latest Browse all 5691


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>