You need to pinvoke the functions residing in your C++ DLL (exported using extern "C"
) from your .NET code using the DllImportAttribute
. You can't reference your C++ DLL like a .NET assembly, and you can't use classes from the DLL, only DllImport
ed C-like functions.
Example from msdn:
using System;
using System.Runtime.InteropServices;
class Example
{
// Use DllImport to import the Win32 MessageBox function.
[DllImport("user32.dll", CharSet = CharSet.Unicode)]
public static extern int MessageBox(IntPtr hWnd, String text, String caption, uint type);
static void Main()
{
// Call the MessageBox function using platform invoke.
MessageBox(new IntPtr(0), "Hello World!", "Hello Dialog", 0);
}
}