I'm trying to create a simple Voip client application using the Linphone NuGet (LinphoneSDK.5.1.73.nupkg).
For that I created a solution with two C# projects (target framework: .net Framework 4.8, ; target platform: x86): one as a wrapper of Linphone (named as My.Voip) and the other for the application itself (named as My.Voip.Client).
In My.Voip, I added the Nuget LinphoneSDK 5.1.73, that I previously downloaded to my computer.
In this project, I created a class with a function that returns the version of Linphone, following the tutorial from Linphone.
using Linphone;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace My.Voip
{
public class Engine
{
public Core StoredCore { get; set; }
public string Version()
{
Factory factory = Factory.Instance;
string assetsPath = Path.Combine(System.IO.Path.GetDirectoryName(Assembly.GetEntryAssembly().Location), "share");
factory.TopResourcesDir = assetsPath;
factory.DataResourcesDir = assetsPath;
factory.SoundResourcesDir = Path.Combine(assetsPath, "sounds", "linphone");
factory.RingResourcesDir = Path.Combine(factory.SoundResourcesDir, "rings");
factory.ImageResourcesDir = Path.Combine(assetsPath, "images");
factory.MspluginsDir = ".";
Core core = factory.CreateCore("", "", IntPtr.Zero);
// You should store the Core to keep a reference to it at all times while your app is alive.
// A good solution for that is to either subclass the Application object or create a Service.
StoredCore = core;
return Core.Version;
}
}
}
In My.Voip.Client, I added a reference to the My.Voip project.
Now, in My.Voip.Client, I created a winform that, on load shows the version of Linphone.
private void Form1_Load(object sender, EventArgs e)
{
My.Voip.Engine x = new My.Voip.Engine();
MessageBox.Show(x.Version());
}
The problem that I'm facing is that i get an error when I invoke the Version method:
System.DllNotFoundException: 'Unable to load DLL 'linphone': The specified module could not be found. (Exception from HRESULT: 0x8007007E)'
The error is traced back to the file ~My.Voip\linphonecs\LinphoneWrapper.cs, line 33104:
static public Linphone.Factory Instance
{
get
{
IntPtr ptr = linphone_factory_get(); //<-Exception is thrown here
Linphone.Factory obj = fromNativePtr<Linphone.Factory>(ptr, true);
return obj;
}
}
The Instance is invoked in the class Engine->function Version->Factory factory = Factory.Instance;
I've tried to change the target platform as x64 and AnyCPU, reference the Nuget directly to the winforms application, but I get always the same error. I've, also, tried to use the Nuget directly from the Linphone repository, and the result is the same error, too.
What do I need to do to run this correctly?