问题描述
目前我有abc.dll这是fortran dll。现在我想从abc.dll调用C#代码。有没有办法从fortran dll调用C#代码?感谢
Sagar
dllexport
)来自另一个本地代码模块。在这种情况下,您需要创建一个托管C ++ dll,它公开了一个本地接口,并在内部将该调用转换为C#代码。编辑:如果托管程序是托管代码,并且您需要执行C# - > Fortran(native) - > C#调用序列,然后将委托作为非托管函数指针在上面的注释中用作链接。但是,如果可执行文件不是托管代码,则需要转到我提到的路线。 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 ?
thanksSagar
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.
这篇关于如何从Fortran dll调用c#代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!