C ++/CLI与VB和VC ++一起使用 [英] C++/CLI being used with VB and VC++

查看:119
本文介绍了C ++/CLI与VB和VC ++一起使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在这里发了好几次贴子,除了很好的建议外,什么也没有得到,所以我又一次带着最近的C ++/CLI头痛回去.在C ++/CLI库中,结果是MyLib.dll.我已经在C#上很好地工作了,但是想在VC ++和VB中生成一些示例代码,而且似乎无法弄清楚如何使这两个代码正常工作.

我可以编译使用以下C#程序:
$ csc/nologo/platform:x86 TestProgram.cs/r:MyLib.dll

我对VB几乎一无所知,也不知道到底有什么不同在VC ++和常规C ++之间.我正在寻找的是有关说服VC ++程序和VB程序与MyLib.dll进行通讯的说明.我在互联网上发现的大多数内容看起来过时,或强制存在.lib文件.

长话短说,从VC ++调用C ++/CLI .dll中定义的函数需要采取什么步骤?和VB代码?

I''ve posted on here several times and gotten nothing but great advice, so I once again return with my most recent C++/CLI headache.

First, I have some native code, which I wrapped in a C++/CLI library, and the result was MyLib.dll. I''ve gotten this working very well with C#, but would like to produce some example code in VC++ and VB, and can''t seem to figure out how to get those two working.

I could compile the C# program using:
$ csc /nologo /platform:x86 TestProgram.cs /r:MyLib.dll

I know pretty much nothing about VB and don''t really know what''s different between VC++ and regular C++. What I''m looking for are instructions on what I need to do to convince a VC++ program and a VB program to talk to MyLib.dll. Much of what I found on the internet either looked dated, or mandated the presence of .lib files.

Long story short, what steps need to be taken to call functions defined in a C++/CLI .dll from VC++ and VB code? Any and all advice is very much appreciated!

推荐答案

csc/nologo/platform:x86 TestProgram.cs/r:MyLib.dll

我知道关于VB几乎没有任何内容,也不真正知道VC ++和常规C ++之间的区别.我正在寻找的是有关说服VC ++程序和VB程序与MyLib.dll进行通讯的说明.我在互联网上发现的大多数内容看起来过时,或强制存在.lib文件.

长话短说,从VC ++调用C ++/CLI .dll中定义的函数需要采取什么步骤?和VB代码?任何意见和建议都将不胜感激!
csc /nologo /platform:x86 TestProgram.cs /r:MyLib.dll

I know pretty much nothing about VB and don''t really know what''s different between VC++ and regular C++. What I''m looking for are instructions on what I need to do to convince a VC++ program and a VB program to talk to MyLib.dll. Much of what I found on the internet either looked dated, or mandated the presence of .lib files.

Long story short, what steps need to be taken to call functions defined in a C++/CLI .dll from VC++ and VB code? Any and all advice is very much appreciated!


Shadowsoal写道:
Shadowsoal wrote:

正在寻找关于我的指示需要说服VC ++程序和VB程序与MyLib.dll对话.

looking for are instructions on what I need to do to convince a VC++ program and a VB program to talk to MyLib.dll.



MyLib.dll是混合模式DLL(使用/clr开关编译),对吗?

与本机代码中的混合模式DLL进行通信非常困难.我想,您需要使用条件编译,并根据编译器选项公开托管和非托管客户端的接口. _MANAGED是将在使用/clr编译开关时定义的宏.利用此宏来决定需要向本机客户端公开的功能.您还需要为本机客户端提供一个头文件,因为它们无法从程序集元数据中读取.

我还没有尝试过上述方法,但是我相信它应该可以解决问题.

:)



MyLib.dll is a mixed mode DLL (compiled using /clr switch), right?

Communicating with a mixed mode DLL from native code is tough. I guess, you need to use conditional compilation and expose the interfaces for managed and unmanaged clients depending upon the compiler options. _MANAGED is a macro which will be defined when /clr compilation switch is used. Make use of this macro to decide the functions you need to expose to native clients. You need to provide a header file as well for native clients as they can''t read from the assembly meta data.

I haven''t tried the above, but I believe it should do the trick.

:)


这篇关于C ++/CLI与VB和VC ++一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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