> I am having problems with my c# wrapper for sipxtapi that is based on
> the VB one on the SIPfoundary site.  My code is producing the following
> exception "Attempted to read or write protected memory. This is often an
> indication that other memory is corrupt." This happens when I call the
> sipxAudioGetOutputDevice via the following DLLImport statement and it is
> the last argument that is causing the problem.  

try like this (this is part of SipxCall wrapper for sipXtapi by Jaroslav Libak):

...

using SIPX_CALL = System.IntPtr;

...

[DllImport(SIPXTAPI_DLL, SetLastError = true, CallingConvention = 
CallingConvention.Cdecl, EntryPoint = "sipxCallGetContactID")]
public extern static SIPX_RESULT sipxCallGetContactID(SIPX_CALL hCall, IntPtr 
szContactAddress, uint iMaxLength);

...

public string ContactID
{
    get
    {
        IntPtr buf = Marshal.AllocCoTaskMem(255);
        try
        {
            if (SipxInterop.sipxCallGetContactID(this.CallHandle, buf, 255) == 
SIPX_RESULT.SIPX_RESULT_SUCCESS)
                return Marshal.PtrToStringAnsi(buf);
            else
                return String.Empty;
        }
        finally
        {
            Marshal.FreeCoTaskMem(buf);
        }
    }
}


--
Best regards, 
Alexey [ [EMAIL PROTECTED] ]

_______________________________________________
sipxtapi-dev mailing list
[email protected]
List Archive: http://list.sipfoundry.org/archive/sipxtapi-dev/

Reply via email to