You need to create a C++ CLR Class library
.
For example:
#pragma once
using namespace System;
class myUnmanaged
{
public:
int a ;
myUnmanaged()
{
a = 2;
}
};
namespace CPPLibrary{
public ref class MyManagedCPP_Class
{
private:
myUnmanaged* myUnmanagedPtr =new myUnmanaged;
public:
MyManagedCPP_Class() { Console::WriteLine("hello C++!"); }
Void MyPrint()
{
Console::WriteLine(myUnmanagedPtr->a);
}
};
}
Call the class in VB project:
Imports System
Imports CPPLibrary
Module Program
Sub Main(args As String())
Dim m As New MyManagedCPP_Class()
m.MyPrint()
Console.WriteLine("Hello World!")
End Sub
End Module
Best regards,
Minxin Yu
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.