Integrating PJSIP 2.6 (PJSUA2) in Xamarin.iOS (C#) [TypeInitializationException]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi PJSIP Mailing List,
 
I am having difficulty integrating PJSIP Native libraries into my Xamarin.iOS project.  I have completed the following steps, but am encountering a System.TypeInitializationException when attempting to create a new Endpoint instance.  I do not understand where in the library it would attempt to JIT on iOS.  Any assistance is much appreciated.


## Libraries / SDK versions:
* Opus Codec Library 1.1.4
* PJSIP 2.6 (PJSUA2)
* Xamarin Studio 6.3
* Xcode 8.3.2
* iOS SDK 10.3 


## Built Opus codec library ([PJSIP + Opus](https://trac.pjsip.org/repos/ticket/1904))

## Built PJSIP library ([PJSIP Getting Started iPhone](https://trac.pjsip.org/repos/wiki/Getting-Started/iPhone))
* Built each architecture individually 
`ARCHS="arm64 armv7 armv7s i386 x86_64"`
* Unified all architectures 
`lipo -arch armv7 armv7/$filename -arch armv7s armv7s/$filename -arch arm64 arm64/$filename -arch i386 i386/$filename -arch x86_64 x86_64/$filename -create -output unified/$filename`

## Added PJSUA2 to Xamarin.iOS project ([Xamarin Native Libraries](https://developer.xamarin.com/guides/ios/advanced_topics/native_interop/))
* Added PJSUA2 Headers
 `/pjsip/unified/pjsua2/*.cs`
* Added PJSUA2 Libraries
`/pjsip/unified/*.a` (skipped libpjsdp.a, since already linked in libpsjua.a)
* Added mtouch extra arguments
`-cxx -gcc_flags "-L${ProjectDir}/lib/ -lg7221codec-apple-darwin_ios -force_load ${ProjectDir}/lib/libg7221codec-apple-darwin_ios.a -lgsmcodec-apple-darwin_ios -force_load ${ProjectDir}/lib/libgsmcodec-apple-darwin_ios.a -lilbccodec-apple-darwin_ios -force_load ${ProjectDir}/lib/libilbccodec-apple-darwin_ios.a -lpj-apple-darwin_ios -force_load ${ProjectDir}/lib/libpj-apple-darwin_ios.a -lpjlib-util-apple-darwin_ios -force_load ${ProjectDir}/lib/libpjlib-util-apple-darwin_ios.a -lpjmedia-apple-darwin_ios -force_load ${ProjectDir}/lib/libpjmedia-apple-darwin_ios.a -lpjmedia-audiodev-apple-darwin_ios -force_load ${ProjectDir}/lib/libpjmedia-audiodev-apple-darwin_ios.a -lpjmedia-codec-apple-darwin_ios -force_load ${ProjectDir}/lib/libpjmedia-codec-apple-darwin_ios.a -lpjmedia-videodev-apple-darwin_ios -force_load ${ProjectDir}/lib/libpjmedia-videodev-apple-darwin_ios.a -lpjnath-apple-darwin_ios -force_load ${ProjectDir}/lib/libpjnath-apple-darwin_ios.a -lpjsip-apple-darwin_ios -force_load ${ProjectDir}/lib/libpjsip-apple-darwin_ios.a -lpjsip-simple-apple-darwin_ios -force_load ${ProjectDir}/lib/libpjsip-simple-apple-darwin_ios.a -lpjsip-ua-apple-darwin_ios -force_load ${ProjectDir}/lib/libpjsip-ua-apple-darwin_ios.a -lpjsua-apple-darwin_ios -force_load ${ProjectDir}/lib/libpjsua-apple-darwin_ios.a -lpjsua2-apple-darwin_ios -force_load ${ProjectDir}/lib/libpjsua2-apple-darwin_ios.a -lpjsua2_wrap -force_load ${ProjectDir}/lib/libpjsua2_wrap.a -lresample-apple-darwin_ios -force_load ${ProjectDir}/lib/libresample-apple-darwin_ios.a -lspeex-apple-darwin_ios -force_load ${ProjectDir}/lib/libspeex-apple-darwin_ios.a -lsrtp-apple-darwin_ios -force_load ${ProjectDir}/lib/libsrtp-apple-darwin_ios.a -lwebrtc-apple-darwin_ios -force_load ${ProjectDir}/lib/libwebrtc-apple-darwin_ios.a -lyuv-apple-darwin_ios -force_load ${ProjectDir}/lib/libyuv-apple-darwin_ios.a -lopus -force_load ${ProjectDir}/lib/libopus.a"`

## Built Debug -> iOS Device
* Compiles and Links without Errors

## Ran built project 
* Encounter TypeInitializationException upon instantiating an Endpoint 
* Pjsua2Manager.cs:164
`var mEP = new Endpoint();`
* Exception
`        System.TypeInitializationException: The type initializer for "pjsua2PINVOKE" threw an exception. ---> System.TypeInitializationException: The type initializer for "SWIGExceptionHelper" threw an exception. ---> System.ExecutionEngineException: Attempting to JIT compile method "(wrapper native-to-managed) pjsua2PINVOKE/SWIGExceptionHelper:SetPendingApplicationException (intptr)" while running with --aot-only. See http://docs.xamarin.com/ios/about/limitations for more information.`
        
          at (wrapper managed-to-native) System.Object:__icall_wrapper_mono_delegate_to_ftnptr (object)
          at (wrapper managed-to-native) pjsua2PINVOKE+SWIGExceptionHelper:SWIGRegisterExceptionCallbacks_pjsua2 (pjsua2PINVOKE/SWIGExceptionHelper/ExceptionDelegate,pjsua2PINVOKE/SWIGExceptionHelper/ExceptionDelegate,pjsua2PINVOKE/SWIGExceptionHelper/ExceptionDelegate,pjsua2PINVOKE/SWIGExceptionHelper/ExceptionDelegate,pjsua2PINVOKE/SWIGExceptionHelper/ExceptionDelegate,pjsua2PINVOKE/SWIGExceptionHelper/ExceptionDelegate,pjsua2PINVOKE/SWIGExceptionHelper/ExceptionDelegate,pjsua2PINVOKE/SWIGExceptionHelper/ExceptionDelegate,pjsua2PINVOKE/SWIGExceptionHelper/ExceptionDelegate,pjsua2PINVOKE/SWIGExceptionHelper/ExceptionDelegate,pjsua2PINVOKE/SWIGExceptionHelper/ExceptionDelegate)
          at pjsua2PINVOKE+SWIGExceptionHelper..cctor () [0x00126] in /Voip.iOS/lib/pjsua2/pjsua2PINVOKE.cs:104 
           --- End of inner exception stack trace ---
          at (wrapper managed-to-native) System.Object:__icall_wrapper_mono_generic_class_init (intptr)
          at pjsua2PINVOKE..cctor () [0x00000] in /Voip.iOS/lib/pjsua2/pjsua2PINVOKE.cs:124 
           --- End of inner exception stack trace ---
          at Endpoint..ctor () [0x00001] in /Voip.iOS/lib/pjsua2/Endpoint.cs:48 
          at Voip.iOS.Main.InCall.Pjsua2Manager._InitLibrary () [0x00013] in Voip.iOS/Main/InCall/Pjsua2Manager.cs:164
_______________________________________________
Visit our blog: http://blog.pjsip.org

pjsip mailing list
pjsip@xxxxxxxxxxxxxxx
http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org

[Index of Archives]     [Asterisk Users]     [Asterisk App Development]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [Linux API]
  Powered by Linux