在C ++中使用非常C#的DLL [英] Using a Very C# DLL in C++

查看:202
本文介绍了在C ++中使用非常C#的DLL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用C#DLL,它在Embarcadero C ++ Builder中有多个.NET类和C#类的引用。
像Point类和String类以及Delegates一样的东西。



我想知道如果.NET引用或C#将会让我失望。我只是想让它挂起来,但我想知道我是否有一些问题可能是由C ++引起的,不希望玩得很好。

解决方案

我给了一个类似的回答您在此问题中的问题。



你基本上想要一个C#/ CLI界面到你的C#代码。



如果你想传递一个C#委托给C ++代码,您可以使用 Marshal :: GetFunctionPointerForDelegate() MSDN )。这给你一个 IntPtr ,您可以调用 ToPointer()作为函数指针传入。


I am trying to use a C# DLL which has multiple references to .NET classes and C# Classes in Embarcadero C++ Builder. Things like the Point class and String class as well as Delegates.

I am wondering if the >NET references or C# ones will mess me up somehow. I am just about to getting it hooked up, but I am wondering if some of the problems I am having could be caused by C++ not wanting to play nice.

解决方案

I gave a similar answer to your problem in this question.

You basically want a C++/CLI interface to your C# code.

If you want to pass a C# delegate to C++ code, you can translate it using Marshal::GetFunctionPointerForDelegate() (MSDN). That gives you a IntPtr that you can call ToPointer() on to pass in as a function pointer.

这篇关于在C ++中使用非常C#的DLL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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