Return to LanScape's home page Go back a page...       Active TopicsActive Topics   Display List of Forum MembersMember List   Knowledge Base SearchSearch   HelpHelp  RegisterRegister  LoginLogin

LanScape VOIP Media Engine™ - Pre-Sales Technical Support
 LanScape Support Forum -> LanScape VOIP Media Engine™ - Pre-Sales Technical Support
Subject Topic: Cannot pass a GCHandle across AppDomains. Parameter name: ha Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
lem1x
Intermediate
Intermediate


Joined: July 06 2012
Posts: 2
Posted: July 12 2012 at 3:29am | IP Logged Quote lem1x

Hi,

I got this kind of error after initalizing VOIP Media Engine.

Code:
Cannot pass a GCHandle across AppDomains.
Parameter name: handle
   at System.Runtime.InteropServices.GCHandle.InternalCheckDomain(IntPtr handle)
   at System.Runtime.InteropServices.GCHandle.FromIntPtr(IntPtr value)
   at System.Runtime.InteropServices.GCHandle.op_Explicit(IntPtr value)
   at MainEventHandler_Unmanaged(Void* hStateMachine, SIP_NOTIFY_TYPE NotifyType, Int32 PhoneLine, TELEPHONY_RETURN_VALUE TelephonyEvent, Void* pUserDefinedData, Void* pEventData)


Here is the code I used:

Code:
public void InitializeVoip()
        {
            var status = _mediaEngine.InitializeMediaEngine(0, 0);
            var startParams = new VoipMediaEngine.START_SIP_TELEPHONY_PARAMS();
            startParams.PersonalityMicrocode = Microcode.LanScapeVME_F186495C_7AFF_4742_ADB7_87EA48A42633;
            // set this to  an even number of lines.
            startParams.NumPhoneLinesRequested = 1;
            startParams.LineMode = VoipMediaEngine.LINE_MODE.SWITCH_LINE;
            startParams.UserNotifyCallbackProc = MediaEngineCallbackProc;
            // set the main callback instance data.
            startParams.UserDefinedData = null;
            startParams.SipPort = 5060;

            // use media engine internal default values.
            startParams.MaxSipMesageLength = 0;
            startParams.SipUdpReceiveBufferSizeInBytes = 0;
            startParams.SipUdpTransmitBufferSizeInBytes = 0;
            startParams.MaxSipMessageReceiveFifoLength = 0;
            startParams.MaxRtpPacketLength = 0;

            startParams.PhoneName = "[CUT]";
            startParams.PhoneDisplayName = "[CUT]";

            startParams.DtmfEnabled = false;
            startParams.DtmfTonesPlayedLocally = false;
            startParams.DtmfTonesTransmittedOutPhoneLines = false;
            startParams.DtmfLocalAudioPlaybackBuffering = 2;
            startParams.DtmfPhoneLineAudioBuffering = 2;

            // use media engine internal default value.
            startParams.DtmfIncomingPhoneLineEventBuffers = 0;

            startParams.CallConferenceEnabled = false;

            startParams.FarEndCallTransferEnabled = false;
            startParams.RandomlyAssignIncomingCallsToPhoneLines = false;

            startParams.MinLocalRtpPort = 8000;
            startParams.MaxLocalRtpPort = 8400;
            startParams.UseSequentialRtpPorts = false;

            var UseAudioDevice = true;
            if (UseAudioDevice)
            {
                startParams.ZeroBasedAudioInDeviceId = VoipMediaEngine.SIP_USE_PREFERED_AUDIO_DEVICE;
                startParams.ZeroBasedAudioOutDeviceId = VoipMediaEngine.SIP_USE_PREFERED_AUDIO_DEVICE;
            }
            else
            {
                startParams.ZeroBasedAudioInDeviceId = VoipMediaEngine.SIP_AUDIO_DEVICE_NOT_USED;
                startParams.ZeroBasedAudioOutDeviceId = VoipMediaEngine.SIP_AUDIO_DEVICE_NOT_USED;
            }

            startParams.AudioRecordBandWidth = VoipMediaEngine.AUDIO_BANDWIDTH.AUDIO_BW_PCM_22K;
            startParams.AudioPlaybackBandWidth = VoipMediaEngine.AUDIO_BANDWIDTH.AUDIO_BW_PCM_22K;

            startParams.PlaybackBufferingDefault = 4;
            startParams.PlaybackBufferingDuringSounds = 4;
            startParams.PhoneLinePlayoutBuffering = 2;
            startParams.PhoneLineTransmitBuffering = 2;

            startParams.LogSipMessages = false;
            startParams.SipLogFileName = string.Empty;

            startParams.EnableEventLogServers = false;
            startParams.EventLogServerList = null;
            startParams.EventLogServerPortList = null;

            startParams.EnablePhoneLineRecording = false;
            startParams.PhoneLineRecordBuffering = 0;

            startParams.MaxMixerLinebuffers = 0;
            startParams.SendLineInitializedEvents = true;
            startParams.StartupFlags = 0;

            GlobProcs.IpAddressStringToBytes("[CUT]", ref startParams.IpAddressOfThisHost);
            try
            {
                status = _mediaEngine.StartSipTelephony(startParams);
                status = _mediaEngine.AddAuthorizationCredentials(
                                        "[CUT]",
                                        "[CUT]",
                                        "[CUT]"
                                        );
                // set the VOIP domain.
                status = _mediaEngine.EnableSipDomain("[CUT]");

                ///////////////////////////////////////////////////
                //
                // IMPORTANT:
                //
                //     Enable the media engine's ability to receive
                //     SIP protocol packets from the network before
                //     configuring registration cycles.
                //
                ///////////////////////////////////////////////////
                status = _mediaEngine.SipTelephonyEnable();

                String[] RegistrarInfo = null;
                int NumRegistrarInfo = GlobProcs.Tokenize("[CUT]", ':', ref RegistrarInfo);
                if (NumRegistrarInfo == 2)
                {
                    int RegistrarPort = int.Parse(RegistrarInfo[1]);


                    // set the time we wait in between failed registrations.
                    status = _mediaEngine.RegistationErrorRetryTime(2000);

                    status = _mediaEngine.EnableSipRegisterServer(
                                        "[CUT]",
                                        false,                                                       // register individual phone lines.
                                        false,                                                       // send register requests to specified regsitar.
                                        RegistrarInfo[0],                                        // registrar server address.
                                        (uint)RegistrarPort,                                   // registrar server port.
                                        3600,          // periodic update interval.
                                        3600,          // registration durstion.
                                        4000,     // response timeout
                                        false                                                       // detect NAT on register cycles.
                                        );
                }
            }
            catch (Exception exception)
            {
            }


Do you have any ideas how to fix it?
Back to Top View lem1x's Profile Search for other posts by lem1x
 
support
Administrator
Administrator


Joined: January 26 2005
Location: United States
Posts: 1666
Posted: July 12 2012 at 7:23am | IP Logged Quote support

Never saw this exception before.

The quickest way to solve this is for you to send a sample project that demonstrates the issue. That way I can debug through the VOIP SDK’s managed code wrapper and the native DLL code to see what is occurring.

Just email a ZIP or RAR archive.


RJ

Back to Top View support's Profile Search for other posts by support Visit support's Homepage
 

If you wish to post a reply to this topic you must first login
If you are not already registered you must first register

  Post ReplyPost New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum






Contact LanScape Hear what the Lawyers have to say How youm may use this site Read your privacy rights