I use dllimport method (PrintBarcode) in c# on a class library's method().
[DllImport(BXLDIR, SetLastError = true, EntryPoint = "PrinterOpen", CallingConvention = CallingConvention.StdCall)]
public static extern Int32 PrinterOpen(string strPort, Int32 lTimeout);
public static bool PrintOrderNoInfos(string orderNo, string printerIP)
{
var infos = GetInfosByOrderNo(orderNo).FirstOrDefault();
var printerOutPortName = String.Format("ETH{0}:9100", printerIP);
BXLModule.PrinterOpen(printerOutPortName, 1000);
}
Then i reference this class lib dll on presentation layer and when i call this method (PrintOrderNoInfos)
var res = OrderInfosHelper.PrintOrderNoInfos("2100022127000700", "20.10.15.58");
an error occurs like
A call to PInvoke function 'InfosByOrderNoLibrary!InfosByOrderNoLibrary.BxlPrint::PrinterOpen' 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.
How can I solve this error?
Thanks in advance.