本机C ++与C#通信 [英] Native C++ communicate with C#

查看:151
本文介绍了本机C ++与C#通信的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

基本上我的代码如下所示

Managed.dll
Managed.cs

Basically my code is looks like below

Managed.dll
Managed.cs

class MyManagedClass
{
public ShowMessage()
{
System.out.println("My Message");
}
}



Wrapper.dll



Wrapper.dll

ref class Wrapper
{

};




Native.lib




Native.lib

class NativeClass
{
public:
void NativeMessage()
{
cout<<"Print Message";
}

}


主要


Main

void main
{
NativeClass ob;
ob.NativeMessage();
}


我的问题是无论何时"ob.NativeMessage();"调用,如何触发MyManagedClass :: ShowMessage().

Wrapper.dll和Managed.dll中引用的Wrapper.dll链接的更强大的Native.lib.

谁能帮我这个忙.


my issue is whenever the "ob.NativeMessage();" called, some how MyManagedClass::ShowMessage() has to be triggered.

And more impotent Native.lib linked in Wrapper.dll and Wrapper.dll referenced in Managed.dll.

Can any one help me on this.

推荐答案

这是一件容易的事.在 Microsoft 中查看此代码.

您当然可以使用您的dll和功能.
It is an easy task. Look at this code from Microsoft.

You could ofcourse use your dll and function.


这篇关于本机C ++与C#通信的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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