I'm currently implementing a render system that are scriptable by XML. While the system is kinda awesome, so far, there is a bit of a steep learning curve for others to use the scripts. So I'm in the process to also implement a editor to the render system. The render system is implemented in C++, the editor will be implemented in Windows Forms (C#).
But im already stumped. I try to call the functions from the dll, but i get a
PInvokeStackImbalance was detected.
error. While reading on about the error, I realize that there is a problem with calling conventions and parameters, or, like the error tells me:
This is likely because the managed PInvoke signature does not match the unmanaged target signature. Check that the calling convention and parameters of the PInvoke signature match the target unmanaged signature.
But, there should match, or am I at fault here?
The call is the following:
[DllImport(DllName, SetLastError = true)]
static unsafe extern void Initalize(IntPtr hWnd);
public unsafe void Start(IntPtr hWnd)
{
Initalize(hWnd);
}
The dll entry is as follow:
namespace hs
{
namespace renderer
{
[...]
__declspec(dllexport) void Initalize(HWND hWnd);
[...]
}
}
I'm, as I said, stumped. First i thought it was the namespaces, but as it finds the entry point, i don't think thats the problem.
Anyone out there who knows the correct way to do this?
Much appreciated.