I am trying to make a C++ native dll, then link that to a dll in C#. So from my understanding to do this, I have put in my C++ dll this:
// dllmain.cpp : Defines the entry point for the DLL application.
#include "stdafx.h"
typedef int IntPtr;
extern "C" __declspec(dllexport) int getInfo(int ID, UINT ID2, UINT buffer, IntPtr ID3);
BOOL APIENTRY DllMain( HMODULE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
return TRUE;
}And then in my C# dll I have put:
[DllImport("test.dll", EntryPoint = "getInfo", CallingConvention = CallingConvention.Cdecl)]
private static extern int getInfo(int ID, uint ID2, ref uint buffer, IntPtr ID3);But when I try and use it, it acts as if it were going to work, then when I run it, it says "getInfo entry point cannot be found in test.dll"
So what am I doing wrong? Thanks.
Also: I didn't declare a body for the "extern" in the C++ part because I am using it as a returning value.