本文介绍了如何从Fortran dll调用c#代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

目前我有abc.dll这是fortran dll。现在我想从abc.dll调用C#代码。有没有办法从fortran dll调用C#代码?



感谢
Sagar

解决方案通常,如果你的程序完全是用本地代码编写的(因为我相信Fortran dll会),你需要调用一个已经导出的方法( 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#代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 11:22