BelledonneCommunications / linphone-xamarin

Linphone.org mirror for linphone-xamarin (git://git.linphone.org/linphone-xamarin.git)
https://www.linphone.org/
GNU General Public License v3.0
26 stars 21 forks source link

Linphone DLL not found when running iOS sample app #9

Closed anders9ustafsson closed 6 years ago

anders9ustafsson commented 6 years ago

Have built and deployed LinphoneXamarin.iOS sample app in Debug mode on my iPhone. When running the app, I get the following exception:

Unhandled Exception: System.DllNotFoundException: linphone Error while resolving expression: Object reference not set to an instance of an object.

[External Code]
0xFFFFFFFFFFFFFFFF in Linphone.LinphoneObject.fromNativePtr at XXX\LinphoneXamarin\LinphoneXamarin\LinphoneXamarin\LinphoneWrapper.cs C# 0x9 in Linphone.Factory.get_Instance at XXX\LinphoneXamarin\LinphoneXamarin\LinphoneXamarin\LinphoneWrapper.cs:12439,5 C# 0x19 in LinphoneXamarin.App..ctor at XXX\LinphoneXamarin\LinphoneXamarin\LinphoneXamarin\App.xaml.cs:25,13 C# 0x9 in LinphoneXamarin.AppDelegate.FinishedLaunching at XXX\LinphoneXamarin\LinphoneXamarin\LinphoneXamarin.iOS\AppDelegate.cs:26,4 C# 0x8 in LinphoneXamarin.IApplication.Main at XXX\LinphoneXamarin\LinphoneXamarin\LinphoneXamarin.iOS\Main.cs:17,4 C#

anders9ustafsson commented 6 years ago

I have tried to run the simulator instead, in both Debug and Release modes, but I still experience the same missing DLL exception.

anders9ustafsson commented 6 years ago

Issue is present both when building/deploying from Visual Studio on Windows and Mac.

anders9ustafsson commented 6 years ago

Found the error!

In the LinphoneWrapper class, the following string constants are defined:

#if WINDOWS_UWP
  public const string BELLE_SIP_LIB_NAME = "bellesip";
  public const string BCTOOLBOX_LIB_NAME = "bctoolbox";
#else
  public const string BELLE_SIP_LIB_NAME = "linphone";
  public const string BCTOOLBOX_LIB_NAME = "linphone";
#endif

However, for iOS, these library names should be linphone.framework/linphone, which is apparent from this definition in the same class:

#if __IOS__
  public const string LIB_NAME = "linphone.framework/linphone";
#else
  public const string LIB_NAME = "linphone";
#endif

As far as I can tell, the simplest approach is therefore to redefine BELLE_SIP_LIB_NAME and BCTOOLBOX_LIB_NAME for Android and iPhone as such:

#else
  public const string BELLE_SIP_LIB_NAME = LIB_NAME;
  public const string BCTOOLBOX_LIB_NAME = LIB_NAME;
#endif
anders9ustafsson commented 6 years ago

As far as I can tell, this issue has been fixed in a recent commit of linphone-xamarin, so I am closing it now.

Adeel984 commented 3 years ago

@anders9ustafsson Sir i'm having same issue in Xamarin.Androind building on Windows. Any help please?

JoeHenderson1962 commented 3 years ago

I'm getting that same error but it looks like it's because IOS isn't defined.