Currently I have the problem that I should migrate a tool which communicates via Cisco TAPI. Currently it is running under a 32bit compilation.
If I switch the compilation set to 64bit and update the nuget package "ATAPI" (by Mark Smith <2>) to the 64bit version.
If I build this and test it, the TAPI logs writes there is a dwSize mismatch. I tried to set an explicity StructLayout for the CiscoDevSpecific-structs (like suggested here <1>) . But the same error appears in the log file.
error message
15:44:51.105 | TSPI_lineGetAddressStatus() TSPI_lineGetAddressStatus returns = 0x00000000
15:44:51.106 | TSPI_lineDevSpecific()
dwRequestID: 0x000105AF hdLine: 0x175B4B30 dwAddressID: 0x00000000 hdCall: 0x00000000 lpParams: 0x202D6E98 dwSize: 32
15:44:51.106 | CSelsiusTSPLine::DevSpecific() [0x00000D32] *ERROR* dwSize mis-match 0x00000020
15:44:51.106 | TSPI_lineDevSpecific() TSPI_lineDevSpecific returns = 0x80000048
eg The struct for a StartCallMonitotoring looks like
[StructLayout(LayoutKind.Explicit, Size = 32)]
public struct CiscoLineDevSpecificStartCallMonitoring
{
[FieldOffset(0)]
public int m_MsgType;
[FieldOffset(8)]
public int m_PermanentLineID;
[FieldOffset(16)]
public int m_MonitorMode; //0= NONE, 1=SILENT, 2=WHISPER, 3=ACTIVE
[FieldOffset(24)]
public int m_ToneDirection; //0=LOCALONLY, 1=REMOTEONLY, 2=BOTH, 3=NOTLOCALORREMOTE
}
The initiliziation like
var cisco = new CiscoLineDevSpecificStartCallMonitoring
{
m_MsgType = (int)CiscoLineDevSpecificType.SLDST_START_CALL_MONITORING,
m_PermanentLineID = permanentIdOfTargetLine,
m_MonitorMode = (int)monitorMode,
m_ToneDirection = (int)PlayToneDirection.PlayToneDirectionNoLocalOrRemote
};
And the calculation of the Bytes looks like:
private static byte[] GetBytes(object msg)
{
var size = Marshal.SizeOf(msg);
var arr = new byte[size];
var ptr = Marshal.AllocHGlobal(size);
Marshal.StructureToPtr(msg, ptr, true);
Marshal.Copy(ptr, arr, 0, size);
Marshal.FreeHGlobal(ptr);
return arr;
}
Thank you for your responds.
<1> https://community.cisco.com/t5/collaboration-documents/tsp-x64-devspecific-dword-size-mismatch-problem/ta-p/3613828 <2> https://github.com/markjulmar/atapi.net