Fortran コード
FUNCTION ComputeSquareRoot(inputValue)
IMPLICIT NONE
!DEC$ ATTRIBUTES ALIAS:'ComputeSquareRoot' :: ComputeSquareRoot
!DEC$ ATTRIBUTES DLLEXPORT :: ComputeSquareRoot
REAL*8 :: inputValue
REAL*8 :: ComputeSquareRoot
ComputeSquareRoot = SQRT(inputValue)
RETURN
END FUNCTION
C# コード
[DllImport("TestingFortranDll.dll", CallingConvention = CallingConvention.Cdecl)]
static extern double ComputeSquareRoot(ref double inputValue);
/// <summary>
/// Wrapper method for ComputeSquareRoot.
/// </summary>
/// <returns></returns>
public static double CallingComputeSquareRoot()
{
var inputValue = 100.0;
return ComputeSquareRoot(ref inputValue);
}
例外
アプリケーションのコンポーネントで未処理の例外が発生しました....
DLL "TestingFortranDll.dll" を読み込めません: 特定のモジュールが見つかりませんでした。(HRESULT:0x8007007E からの例外)
この例外は、SQRT などの暗黙的な関数を使用しようとした場合にのみ発生します。