我如何调用C ++ / CLI(.NET)的标准,非托管non-.NET应用程序的DLL? [英] How do I call C++/CLI (.NET) DLLs from standard, unmanaged non-.NET applications?

查看:148
本文介绍了我如何调用C ++ / CLI(.NET)的标准,非托管non-.NET应用程序的DLL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在非托管的世界,我可以写一个__declspec(dllexport)的,或者使用DEF文件揭露一个函数可以调用的DLL。 (因为名字改编C ++中的__stdcall的,我把别名到DEF文件,以便某些应用程序可以重新使用某些导出的DLL函数)。现在,我很感兴趣的是能够从公开一个入口点函数.NET程序集,在非托管的方式,但它进入DLL中的.NET风格的功能。这是可能的,在一个简单而直接的方式?

In the unmanaged world, I was able to write a __declspec(dllexport) or, alternatively, use a .DEF file to expose a function to be able to call a DLL. (Because of name mangling in C++ for the __stdcall, I put aliases into the .DEF file so certain applications could re-use certain exported DLL functions.) Now, I am interested in being able to expose a single entry-point function from a .NET assembly, in unmanaged-fashion, but have it enter into .NET-style functions within the DLL. Is this possible, in a simple and straight-forward fashion?

我有什么是我穿过的DLL(插件)实现一些复杂的数学已经扩展第三方程序。然而,第三方程序有没有办法对我来说,可视化计算。我想以某种方式把这些pre-写数学函数,编译成一个单独的DLL(但在.NET中使用C ++ / CLI),但再加入钩子函数,所以我可以呈现什么引擎盖下回事一个.NET用户控件。我不知道如何揉合.NET东西与非托管的东西,或者是到谷歌来完成这项任务。

What I have is a third-party program that I have extended through DLLs (plugins) that implement some complex mathematics. However, the third-party program has no means for me to visualize the calculations. I want to somehow take these pre-written math functions, compile them into a separate DLL (but using C++/CLI in .NET), but then add hooks to the functions so I can render what's going on under the hood in a .NET user control. I'm not sure how to blend the .NET stuff with the unmanaged stuff, or what to Google to accomplish this task.

的具体建议,以完成在我所描述将是有益的方式呈现。谢谢你。

Specific suggestions with regard to the managed/unmanaged bridge, or alternative methods to accomplish the rendering in the manner I have described would be helpful. Thank you.

推荐答案

您是否使用C ++ / CLI,因为你想,还是因为你觉得你要导出功能?

Do you use C++/CLI because you want to, or because you think you have to to export functions?

在后一种情况下,检查出我的非托管出口,它允许你声明非托管的出口在C#中相当于的DllImport如何工作的。

In case of the latter, check out my unmanaged exports, which allows you to declare unmanaged exports in C# equivalent to how DllImport works.

internal class Sample
{
  [DllExport("_export_test", CallingConvention.Cdecl)]
  static int Test(int a)
  {
     return a + 1;
  }
}

这篇关于我如何调用C ++ / CLI(.NET)的标准,非托管non-.NET应用程序的DLL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆