Answer the question
In order to leave comments, you need to log in
What is the correct way to call a function from a loaded C# DLL in C++?
I'm trying to load a DLL written in C# in C++
Main program:
HINSTANCE hMyDLL = LoadLibrary(L"ClassLibrary1.dll");
if (NULL == hMyDLL) {
std::cout << "LoadLibrary failed\n";
getchar();
return -1;
}
typedef int (WINAPI * function) ();
function f = (function)GetProcAddress(hMyDLL, "Class1.test");
if (NULL == f) {
std::cout << ":(\n";
}
namespace ClassLibrary1 {
public class Class1 {
public static int test() {
return 5;
}
}
}
Answer the question
In order to leave comments, you need to log in
https://github.com/3F/DllExport
"Out of the box" it seems like nothing, except for COM
Microsoft has an article on MSDN about this, https://support.microsoft.com/en-us/help/828736/ho... .
In short, they offer to work through COM.
Even earlier I came across something similar - https://www.codeproject.com/Tips/695387/Calling-Cs... .
The bottom line is that you can write managed code in C ++, and there, you can add fully exported functions, according to the author. I advise you to pay attention.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question