导出托管成员以便能够以非托管代码进行访问 [英] Exporting managed members to be able to access in unmanaged code

查看:94
本文介绍了导出托管成员以便能够以非托管代码进行访问的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hi Team,

我们在托管cpp项目中有以下代码,我们希望在非托管代码中使用函数XYZ,但我们看到链接器错误'未解决的令牌XYZ'。任何人都可以建议如何将XYZ函数导出为非托管代码吗?

We are having the following code in managed cpp project and we would like use the function XYZ  in unmanaged code, but we are seeing linker error 'unresolved token XYZ '. Can anyone suggest how to export the XYZ function to unmanaged code?

public ref class TempRemoteObject : public MarshalByRefObject
{	// TODO: Add your methods for this class here.

public:
	int XYZ(); 
};

我们尝试使用__declspec(dllexport),但我们收到错误消息'托管类型memebrs无法使用  __ declspec(dllexport)/ __declspec( dllimport的)"。这是一个阻塞问题。

We have tried using __declspec(dllexport) but we are getting the error with message 'Managed type memebrs cannot use __declspec(dllexport)/ __declspec(dllimport)'. This is a blocking issue.

非常感谢任何帮助。

问候,

Sirisha

sirisha

推荐答案

你已经定义了int XYZ( ),但你似乎没有它的实现。您可以更改您的班级定义来实施它:

You've defined int XYZ(), but you don't appear to have an implementation of it. You can either alter your class definition to implement it:

public:

  int XYZ()

  {

   返回0;

  }

public:
  int XYZ()
  {
    return 0;
  }

... 或单独实现:

... or implement it separately:

int TempRemoteObject :: XYZ()

{

 返回0;

}


这篇关于导出托管成员以便能够以非托管代码进行访问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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