Ошибка при работе с компонентой CipherLabTCP8_x86_64_1_0_5_14.dll

Страницы: 1
RSS
Ошибка при работе с компонентой CipherLabTCP8_x86_64_1_0_5_14.dll, На версии CipherLabTCP8_x86_64_1_0_5_11.dll - всё нормально!
 
При использовании в проекте C# компоненты версии CipherLabTCP8_x86_64_1_0_5_11.dll - нет проблем, при использовании CipherLabTCP8_x86_64_1_0_5_14.dll - программа падает с исключением в неуправляемом коде компоненты:


Код
Вызвано исключение по адресу 0x00007FFE75EA1340 (cipherlabtcp8_x86_64_1_0_5_14.dll) в Logos_TSD_Gate.exe: 
0xC0000005: нарушение прав доступа при чтении по адресу 0x0000000000000068.


Прошу разработчиков помочь. Спасибо.
Изменено: shuum - 17.08.2020 05:05:09
 
Добрый день, опишите последовательность действий для воспроизведения проблемы.
 
Добрый день, Павел. Да всё довольно стандартно, C# (visual studio 2019, целевая среда - .net 4.5) код без изысков почти как в вашем примере (приложение собирается под x64):
Код
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate System.Int32 VCallback(IntPtr lparams, IntPtr handle);

#region Библиотека Cipherlab
[DllImport("CipherLabTCP8_x86_64_1_0_5_14.dll", EntryPoint = "cipherlabtcpCreate")]
static extern int CipherlabtcpCreate(ref IntPtr ptrtohandle);
[DllImport("CipherLabTCP8_x86_64_1_0_5_14.dll", EntryPoint = "cipherlabtcpDestroy")]
static extern int CipherlabtcpDestroy(IntPtr handle);
[DllImport("CipherLabTCP8_x86_64_1_0_5_14.dll", EntryPoint = "cipherlabtcpSetEventMessage")]
static extern int CipherlabtcpSetEventMessage(IntPtr handle, IntPtr hwnd, int messageid, IntPtr lparam);
[DllImport("CipherLabTCP8_x86_64_1_0_5_14.dll", EntryPoint = "cipherlabtcpSetEventCallback")]
static extern int CipherlabtcpSetEventCallback(IntPtr handle, VCallback callbackfunc, IntPtr lparam);
[DllImport("CipherLabTCP8_x86_64_1_0_5_14.dll", EntryPoint = "cipherlabtcpGetProperties")]
static extern int CipherlabtcpGetProperties(IntPtr handle, out int Port, out int SaveMethod, out int Debug);
[DllImport("CipherLabTCP8_x86_64_1_0_5_14.dll", EntryPoint = "cipherlabtcpSetProperties")]
static extern int CipherlabtcpSetProperties(IntPtr handle, int Port, int SaveMethod, int Debug);
[DllImport("CipherLabTCP8_x86_64_1_0_5_14.dll", EntryPoint = "cipherlabtcpGetLastError")]
static extern int CipherlabtcpGetLastError(IntPtr handle, out int lasterror);
[DllImport("CipherLabTCP8_x86_64_1_0_5_14.dll", EntryPoint = "cipherlabtcpStart")]
static extern int CipherlabtcpStart(IntPtr handle);
[DllImport("CipherLabTCP8_x86_64_1_0_5_14.dll", EntryPoint = "cipherlabtcpStop")]
static extern int CipherlabtcpStop(IntPtr handle);
[DllImport("CipherLabTCP8_x86_64_1_0_5_14.dll", CharSet = CharSet.Unicode, EntryPoint = "cipherlabtcpGetSerialNumber")]
static extern int CipherlabtcpGetSerialNumber(IntPtr handle, IntPtr eventhandle, StringBuilder NumberTSD);
[DllImport("CipherLabTCP8_x86_64_1_0_5_14.dll", CharSet = CharSet.Unicode, EntryPoint = "cipherlabtcpGetSerialNumberA")]
static extern int CipherlabtcpGetSerialNumberA(IntPtr handle, IntPtr eventhandle, StringBuilder NumberTSD);
[DllImport("CipherLabTCP8_x86_64_1_0_5_14.dll", CharSet = CharSet.Unicode, EntryPoint = "cipherlabtcpGetEvent")]
static extern int CipherlabtcpGetEvent(IntPtr handle, IntPtr eventhandle, StringBuilder messagebuf);
[DllImport("CipherLabTCP8_x86_64_1_0_5_14.dll", CharSet = CharSet.Unicode, EntryPoint = "cipherlabtcpGetData")]
static extern int CipherlabtcpGetData(IntPtr handle, IntPtr eventhandle, out int NumberDB, out int NumberForm, StringBuilder Field1, StringBuilder Field2, StringBuilder Field3, StringBuilder Field4, StringBuilder Field5, StringBuilder Field6, StringBuilder Field7, StringBuilder Field8);
[DllImport("CipherLabTCP8_x86_64_1_0_5_14.dll", CharSet = CharSet.Unicode, EntryPoint = "cipherlabtcpAnswer")]
static extern int CipherlabtcpAnswer(IntPtr handle, IntPtr eventhandle, string OutField1, string OutField2, string OutField3, string OutField4, string OutField5, string OutField6, string OutField7, string OutField8, string NewRow, string NewForm);
[DllImport("CipherLabTCP8_x86_64_1_0_5_14.dll", CharSet = CharSet.Unicode, EntryPoint = "cipherlabtcpSendMessage")]
static extern int CipherlabtcpSendMessage(IntPtr handle, string NumberTSD, string TextOfMessage);
[DllImport("CipherLabTCP8_x86_64_1_0_5_14.dll", CharSet = CharSet.Unicode, EntryPoint = "cipherlabtcpSendWarning")]
static extern int CipherlabtcpSendWarning(IntPtr handle, string NumberTSD, string TextOfMessage);
[DllImport("Kernel32.dll", CharSet = CharSet.Auto)]
#endregion

static IntPtr m_server = IntPtr.Zero;
static readonly int m_port = 1024;

const int WM_APP = 0x8000;
const int MAXSNSIZE = 256;
const int MAXFIELDSIZE = 256;
readonly VCallback TSDCallBack = new VCallback(TSDCallbackFunc);

private static int TSDCallbackFunc(IntPtr lparams, IntPtr handle)
{
   int res;
    StringBuilder sbsn = new StringBuilder(MAXSNSIZE);
   StringBuilder sbcmd = new StringBuilder(MAXSNSIZE);

   res = CipherlabtcpGetEvent(m_server, handle, sbcmd);
   string command = sbcmd.ToString();

   res = CipherlabtcpGetSerialNumber(m_server, handle, sbsn);
   string serialnumber = sbsn.ToString();
   return 0;
}

// Кнопка запуска сервера
private void ButtonStartServer_Click(object sender, EventArgs e)
{
   int res;
   
   res = CipherlabtcpCreate(ref m_server);
   res = CipherlabtcpSetEventCallback(m_server, TSDCallBack, IntPtr.Zero);
   res = CipherlabtcpSetProperties(m_server, Global.m_port, 1, checkBoxDebug.Checked ? 1 : 0);
   // Вот тут крашимся на версии либы 1.0.5.14, а на 1.0.5.11 всё норм!
   res = CipherlabtcpStart(m_server);
}
Изменено: shuum - 17.08.2020 12:17:22
 
Т.е. падает при старте сервера?
Попробуйте эту версию библиотеки: https://scancode.ru/forum/?PAGE_NAME=message&FID=33&TID=12388&TITLE_SEO=1238...
Попутно пару багов исправил.
 
Все отлично - не падает, работает! Спасибо большое!
Страницы: 1