Hi,
I have a C++ dll that I created myself.
It has a function exported like so:
__declspec(dllexport) int WINAPI StartServer()
Now I can call this function from another C++ test application by doing the following:
__declspec(dllimport) int WINAPI StartServer();
Then just call the function StartServer().
My question is how do I call this same function using a Visual C# application? I have tried adding it as a reference but VisualStudio wont allow me.
I have also tried the following:
using System.Runtime.InteropServices;
public partial class Form1 : Form
{
const string _dllLocation = "ServerDLL.dll";
[DllImport(_dllLocation)]
static extern int StartServer();
private void button1_Click(object sender, EventArgs e)
{
StartServer(); <- ERROR HERE
}
}
But when I come to the StartServer() in the button1_Click function I get the following error:
DLLNotfoundexception
Unable to load DLL 'ServerDLL.dll' The specified module could not be found.....
What am I doing wrong here??
Thank for your help.