C++中如何调用C#写的DLL

realshouxian9 2007-01-10 10:36:00
最近在写c++程序的时候需要使用到一个c#写的dll,在该dll中有一些抽象接口和类,在c#代码中使用该dll的code如下:
XboxManagerClass XeManager;
XboxConsole XeConsole = null;
XeConsole = XeManager.OpenConsole(ConsoleStr);
XeConsole.FindConsole(3,10);

其中XboxManagerClass是dll中的class,XboxConsole 是其中的一个抽象接口,OpenConsole的原型是public abstract new XDevkit.XboxConsole OpenConsole ( System.String XboxName )

如果我在c++代码中需要做同样的事情,请问该如何?(在C#代码里,工程中通过add reference直接将dll加载)
...全文
515 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
ChrisAK 2007-01-11
  • 打赏
  • 举报
回复
使用C++/CLI或通过COM调用
realshouxian9 2007-01-10
  • 打赏
  • 举报
回复
// Try to load XDevkitDLL.
FString XeToolsDllFileName = FString(appBaseDir()) + TEXT("\\Xenon\\Interop.XDevkit.dll");

XeToolsDllHandle = appGetDllHandle( *XeToolsDllFileName );

if( !XeToolsDllHandle )
{
appDebugMessagef(TEXT("Couldn't bind to %s."), *XeToolsDllFileName );
return;
}
gcroot<XboxManagerClass> xboxmanage = new XboxManagerClass();

-----------------------------------------------------------------------------------
error C2065: 'gcroot' : undeclared identifier
error C2061: syntax error : identifier 'XboxManagerClass'
error C2065: 'xboxmanage' : undeclared identifier
error C2065: 'XboxManagerClass' : undeclared identifier


真相重于对错 2007-01-10
  • 打赏
  • 举报
回复
#import "yourcs.dll"


...
gcroot<youcsclass>* ....

7,540

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 VC.NET
社区管理员
  • VC.NET社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧