Hi.
I am writing an integration DLL (automation) in C# that loads an unmanaged 3rd party DLL.
The 3rd party dll is an integration dll used to communicate with a payment terminal.
Since this 3rd party DLL is written in unmanaged code, there is marshalling done while communication with this.
The solution works ok when testing it under a .Net test program in Visual Studio 2010
and also when testing it under Dynamics Nav Classic, but not for one function; Offline payment.
When testing for "offline" transaction on the payment terminal it crashes under Dynamics Nav Classic, but not under the .Net test program.
The running code is the same as for online (which is working under both Nav and .Net) but with one difference:
During offline payment a call back function that returns a string is called.
When control is returned to the 3rd party DLL from my code, Nav crashed.
Several other call back are also called and does not cause crash, but none of those call back function is returning a string.
This leads me to believe that there is a problem with the definition of the call back.
[DllImport("flxdrv.dll", EntryPoint = "_flxInitCallbackVB@8", ExactSpelling = true, CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern void flxInitCallback(FLX_CALLBACK methodId, PcbStopListDelegate del);
public delegate void PcbStopListDelegate([MarshalAs(UnmanagedType.BStr)]ref String code, ref int rc);
PcbStopListDelegate pcbStopListDelegate;
public void Flx_RegisterCallBacks()
{
pcbStopListDelegate = new PcbStopListDelegate(PcbStopList);
flxInitCallback(FLX_CALLBACK.FLX_CALLBACK_STOPLIST, pcbStopListDelegate);
}
private void PcbStopList(ref String code, ref int rc)
{
code = "123456,00";
rc = 1;
return;
}
Any suggestions on why the code crashes under Dynamics Nav?