How would I use DLLImport pinvoke to invoke a function i wrote in a class in an unmanaged DLL?
It always throws that the entry point doesn’t exist in the dll.
EX:
class Foo
{
int __declspec(dllexport) Bar() {return 0;}
};
Bar is in the Foo class.
when I use pinvoke as:
[DLLImport("Test.dll")]
public static extern int Bar();
When using it i get an exception saying that the entry point does not exist in the DLL.
Is it possible to call functions directly from classes?
Not easily…
To call a member function, the first “hidden” argument has to be a pointer to the C++ class who’s member function you are calling.
And C++ functions are name mangeled, so you need to find the name mangeled name of the function you are calling.
In short: It is easier to create a C++/CLI wrapper of your C++ class to do this.