How to call a Fortran DLL from C#

JoePlanet20
JoePlanet20 used Ask the Experts™
on
This link provides an example of how to call a
Fortran DLL from VB.NET

http://h18009.www1.hp.com/fortran/examples/vb-example2.html

Can anybody show me the equivalent call in C#?

Thanks a lot.
Joe
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Commented:
Hi,
Just a simple example - hope this helps

// csc *.cs
// calldll

using System;
using System.Runtime.InteropServices;

public class CallDll {
  public static void Main() {
    MessageBoxA(0, "Hello", "Caption", 0);
    MessageBoxW(0, "\u4e00", "Caption", 0);
  }

  [DllImport("user32.dll")]
  public static extern int MessageBoxA(int h, string message, string caption, int type);

  [DllImport("user32.dll")]
  public static extern int MessageBoxW(int h, [MarshalAs(UnmanagedType.LPWStr)] string message, [MarshalAs(UnmanagedType.LPWStr)] string caption, int type);
}

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial