2
I am trying to import a DLL generated via C# in C.
I’m using the methods LoadLibrary
to load the DLL, but when using the GetProcAddress
the return is always null
. I used the GetLastError
and the error code is 127, which means "Function not found".
Code C#:
using RGiesecke.DllExport;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
namespace Testando
{
[ComVisible(true)]
[Guid("5295bba9-fd9b-474d-bd6a-2f7eef51ab71")]
public class Teste1
{
public int LaVai()
{
return 1;
}
}
}
Code C:
HMODULE hModule = LoadLibrary("Testando.dll");
if(hModule == NULL){
printf("null");
}else{
printf("not null");
}
_TestFunc = (TestFunc) GetProcAddress(hModule, TEXT("LaVai"));
if(_TestFunc == NULL){
printf("null");
printf("%d",GetLastError());
}else{
printf("not null");
}
return 0;
What is missing?