VB.NET 到 C++/CLI:如何将 VB.NET DLL 文件导入 C++/CLI?
我想将 VB.NET DLL 文件导入到 C++/CLI 中。我在引用 DLL 文件时遇到问题。我试图找到教程,但没有运气,特别是我通常找到如何通过 COM 将托管库直接导入本机代码。我想将现有的 VB.NET DLL 文件导入到我的 C++/CLI 项目中。
我是否需要头文件或声明文件才能导入和使用 VB.NET DLL 文件?
Foo.vb
Public Module Foo
Public Function Bar(ByVal a As Integer, ByVal b As Integer) As Boolean
Return a > b
End Function
End Module
Mixed.cpp
#include "stdafx.h"
#using "..\Foo\bin\Debug\Foo.dll"
using namespace System;
int main(array<System::String ^> ^args)
{
bool i = Foo::Bar(10,1);
Console::WriteLine(i);
return 0;
}
I would like to import a VB.NET DLL file into C++/CLI. I am having trouble referencing my DLL file. I have tried to find tutorials but with no luck, in particular, I usually find how to import managed libraries directly into native code through COM. I would like to import an existing VB.NET DLL file into my C++/CLI project.
Do I require a header file or a declaration file to import and use my VB.NET DLL file?
Foo.vb
Public Module Foo
Public Function Bar(ByVal a As Integer, ByVal b As Integer) As Boolean
Return a > b
End Function
End Module
Mixed.cpp
#include "stdafx.h"
#using "..\Foo\bin\Debug\Foo.dll"
using namespace System;
int main(array<System::String ^> ^args)
{
bool i = Foo::Bar(10,1);
Console::WriteLine(i);
return 0;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试查看非托管 C++ 到 C# 互操作(取代 CCW),尤其是 Kuldeep_s 的上一篇文章。它是关于通过托管 C++ 从非托管 C++ 访问 C# DLL 文件。如果您跳过非托管 C++ 位,它将符合您的场景(调用 C# DLL 与 VB.NET DLL 应该没有任何区别)。
Try looking at the discussion in Unmanaged C++ to C# interop (replacing CCW), especially Kuldeep_s last post. It's about accessing a C# DLL file from unmanaged C++ via managed C++. If you skip the umanaged C++ bit it would match your scenario (calling a C# DLL vs a VB.NET DLL shouldn't make any difference).