如何制作 PInvokeable DLL
我正在尝试编写一个需要一遍又一遍地执行冗长算法的程序,因此 C++ 对我来说似乎是显而易见的选择。不过,为了让它看起来美观,也为了让它的其他功能更容易实现,我用 C# 构建了它,并用 C++ 编写了算法。
据我所知,在 C# 程序中使用 C++ 函数的最佳方法是 PInvoke 它。但是,当我尝试从 DLL 中 PInvoke 函数时,出现错误:
“无法在 DLL 中找到名为
当我创建 DLL 时,我使用了 Visual C++并创建了一个 Win32 控制台应用程序,从选项中选择了 DLL,并在 test.cpp 文件中创建了该函数。我做错了什么?
I am trying to make a program which will need to execute a lengthy algorithm over and over again, so C++seemed like the obvious choice to me. However, in order to make it look aesthetically pleasing, and to make its other functions easier to make, I built it in C# and made the algorithm in C++.
As far as I am aware, the best way for me to use the C++ function in my C# program is to PInvoke it. However, when I try to PInvoke the function from the DLL, I get an error saying
"Unable to find an entry point named <name> in DLL"
When I made my DLL, I used Visual C++ and created a Win32 Console application, selected DLL from the choices, and created the function in the test.cpp file. What did I do wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要导出本机DLL中的函数。
You need to export the function in the native DLL.