This is to load C# DLL from C++ and call its functions…
#include "pch.h"
#include <iostream>
#include<Windows.h>
#include<string>
using namespace std;
int main()
{
typedef int(__cdecl* _add)(int a, int b);
HMODULE lib = LoadLibrary(L"C:\\Users\\Thiha\\LIB\\bin\\x64\\Release\\ClassLibrary1.dll");
if (lib == NULL)
{
std::cout << "Error loading DLL..." << std::endl;
return 1;
}
// Just testing Add function from C# DLL
auto pAdd = (_add)GetProcAddress(lib, "Add");
int c = pAdd(5, 7);
// Calling printLabel_Sharp function from C# DLL
typedef void(__cdecl* _printLabel_Sharp)();
auto printLabel = (_printLabel_Sharp)GetProcAddress(lib, "printLabel_Sharp");
printLabel();
}