Assembly.Load is for .NET (managed) assemblies only. For native DLLs you need to use PInvoke.
- http://fortranwiki.org/fortran/show/C%23+Interoperability
- http://software.intel.com/en-us/articles/calling-fortran-function-or-subroutine-in-dll-from-c-code/
Given the following (Intel) Fortran subroutine:
subroutine DoWork(n, A)
!DEC$ ATTRIBUTES DLLEXPORT :: DoWork
!DEC$ ATTRIBUTES ALIAS: 'DoWork' :: DoWork
!DEC$ ATTRIBUTES REFERENCE :: n, A
integer, intent(in) :: n
real(8), dimension(n, n), intent(inout) :: A
end subroutine
Use the following method signature in the C# code.
[DllImport("FortranStuff.dll", EntryPoint = "DoWork", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern void DoWork(ref int n, [In, Out] double[,] A);
In this example, FortranStuff.dll needs to be in the same directory as the calling assembly. You could modify the attribute to use a relative or absolute file path ("..\bin\FortranStuff.dll"), but I would recommend just placing it side by side to reduce confusion.