通过dll为vb.net导出C ++类 [英] Export C++ Class through dll for vb.net
问题描述
以allah的名义
玩得开心
摘要我想发送给我自己的类(用c ++)到vb.net,这样在vb.net中我就可以使用那个类了,它的子结构,类,变量,函数,....
i在Google中搜索了很多,msdn.microsoft,codeproject,stackoverflow,...这样做,但我不能。最后我在OCXActiveX项目上工作,部分工作,而不是完全。例如在activeX项目中,我无法访问子类和...来自vb.net。
我错了还是不可能来自activeX?
你可以帮帮我吗?
提前谢谢
为什么不呢只是将C ++类构建为CLR DLL程序集并直接从VB代码引用该类?这样C ++类就是一个.NET类,您可以在VB应用程序中对它进行处理。
Griff的响应绝对是可行的方法。
按如下方式更改代码:
namespace mydll
{
public ref 类 class1
{
public :
class1()
{
inside = gcnew class2;
}
ref class class2
{
public :
int x;
}
里面;
};
};
inside成为类型为class2的成员变量。你的vb.net代码如下所示:
dim a as new mydll.class1
a.inside.x = 4
in the name of allah
have a good time
in summary i want send my own class (in c++) to vb.net so that in the vb.net i can use that class and it's sub structs,class,variables,functions,... .
i searched a lot in google,msdn.microsoft, codeproject,stackoverflow ,... for doing this, but i couldn't. at finally i worked on "OCX" ActiveX project and work partly , not completely. for example in the activeX project i couldn't access the sub class and ... from vb.net.
do i was wrong or it's impossible from activeX?
can you help me ?
thanks in advance
Why not just build the C++ class as a CLR DLL assembly and reference the class directly from your VB code? That way the C++ class is a .NET class and you can treat it as such in your VB application.
Griff's response is definitely the way to go.
Change your code as follows:
namespace mydll { public ref class class1 { public: class1() { inside = gcnew class2; } ref class class2 { public: int x; } inside; }; };
"inside" becomes the member variable whose type is class2. Your vb.net code would look like this:
dim a as new mydll.class1 a.inside.x=4
这篇关于通过dll为vb.net导出C ++类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!