I am trying to call c# dll functions in c++.
Problem is that FPlatformProcess::GetDllExport() returns null.
This is c# code.
[DllExport("Add", CallingConvention = System.Runtime.InteropServices.CallingConvention.StdCall)]
static public int Add(int a, int b)
{
return a + b;
}
This is c++ code.
void* DllHandle = nullptr;
if (DllHandle == nullptr)
{
typedef int(*_Add)(int a, int b);
FString DllPath = FPaths::Combine(*FPaths::ProjectPluginsDir(), TEXT("AndroidAPITemplate/ThirdParty/AllegWifi/"), TEXT("ClassLibrary1.dll"));
if (FPaths::FileExists(DllPath))
{
DllHandle = FPlatformProcess::GetDllHandle(*DllPath);
if (DllHandle)
{
_Add Add = nullptr;
FString ProcName = "Add";
Add = (_Add)FPlatformProcess::GetDllExport(DllHandle, *ProcName);
if (Add)
return Add(2, 2);
}
}
}
FPlatformProcess::FreeDllHandle(DllHandle);
DllHandle = nullptr;
return 100000;