tags:

views:

358

answers:

2

Hi,

Currently I have abc.dll which is fortran dll. Now I want to call C# code from abc.dll. Is there any way to call the C# code from fortran dll ?

thanks Sagar

+2  A: 

Typically, if your program is written entirely in native code (as I believe the Fortran dll would be), you'll need to call a method that's been exported (dllexport) from another native code module. In this case, you'll want to create a Managed C++ dll that exposes a native interface and internally makes the call into the C# code.

Edit: If the hosting program is managed code, and you need to do a C#->Fortran (native)->C# calling sequence, then delegates as unmanaged function pointers can be used as linked in the comments above. However, if the executable is not managed code, you'll need to go the route I mentioned.

280Z28
+3  A: 

Compilers supporting recent Fortran language features (the 2003 standard) will support C-interoperation. You interface with other code through its C interface, using the ISO_C_BINDING module and the BIND construct. Most recent compilers have it, it's standard and you can find a lot of documentation (like this one) by Google'ing the keyword ISO_C_BINDING.

FX