I have an open source C++ DLL
actually it's a plugin dll from a CRX extension that i'm trying to call it's function in Visual Studio With C#
This extension is a Google chrome-screen-capture
I manage to create the Code that talked with the DLL But i have no idea how to call it's functions.
This is my CODE:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
namespace ConsoleApplication1
{
class Program
{
[StructLayout(LayoutKind.Sequential, Pack = 1)]
private class Sample
{
public Int32 length;
public String value;
}
[DllImport("C:\\Users\\Ofir\\Documents\\Visual Studio 2010\\Projects\\ConsoleApplication1\\ConsoleApplication1\\bin\\Debug\\screen_capture.dll")]
private static extern void NP_Initialize();
static void Main(string[] args)
{
Sample s = new Sample();
s.length = 0;
s.value = "Huhu";
NP_Initialize(); <-- I get an ERROR here :
}
}
}
ERROR : PInvokeStackImbalance was detected Message: A call to PInvoke function 'ConsoleApplication1!ConsoleApplication1.Program::NP_Initialize' has unbalanced the stack. 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.
What can i do?
EDIT: For Example if i use NP_GetEntryPoints() it will request a pointer with the type of NPPluginFuncs.
Exaple:NPError WINAPI NP_GetEntryPoints(NPPluginFuncs* pFuncs)
This is the type it's request:
typedef struct _NPPluginFuncs {
uint16 size;
uint16 version;
NPP_NewUPP newp;
NPP_DestroyUPP destroy;
NPP_SetWindowUPP setwindow;
NPP_NewStreamUPP newstream;
NPP_DestroyStreamUPP destroystream;
NPP_StreamAsFileUPP asfile;
NPP_WriteReadyUPP writeready;
NPP_WriteUPP write;
NPP_PrintUPP print;
NPP_HandleEventUPP event;
NPP_URLNotifyUPP urlnotify;
JRIGlobalRef javaClass;
NPP_GetValueUPP getvalue;
NPP_SetValueUPP setvalue;
} NPPluginFuncs;
But i have no idea how to build this type and send it. I want to accomplish to build a function in IE toolbar and then use the functions in this DLL . This way i can use the screen-capture in IE.
EDIT2: WHEN i'm calling the NP_Shutdown() function it's OK. everything is clear and no exception is popping out. so i guess it's all in the type that i send to the other function. but how would i send this kind of type?