0
votes

I am using Xamarin forms to create a chat application and to achieve that i am using Sharp.XMPP library from Nuget but i ran into issues.

It was stated that it doesn't support in PCL at here

So i converted the project into shared .net standard library following this blog

After adding following code

    using Sharp.Xmpp.Client;


    async void OnLoginButtonClicked(object sender, EventArgs e)
    {
        var user = new User
        {
            Username = usernameEntry.Text,
            Password = passwordEntry.Text
        };

        string hostname = "localhost";
        string username = user.Username;
        string password = user.Password;

        using (var client = new XmppClient(hostname, username, password))
        {
            client.Connect();
            messageLabel.Text = "Login Success";
            client.SendMessage("axcl@localhost", "juyugygyg");
        }
    }

Error Recieved :

    Severity    Code    Description Project File    Line    Suppression State
    Error       Exception while loading assemblies: System.IO.FileNotFoundException: Could not load assembly 'Sharp.Xmpp, Version=1.0.2.2, Culture=neutral, PublicKeyToken='. Perhaps it doesn't exist in the Mono for Android profile?
    File name: 'Sharp.Xmpp.dll'
       at Java.Int        rop.Tools.Cecil.DirectoryAssemblyResolver.Resolve(AssemblyNameReference reference, ReaderParameters parameters)
       at Xamarin.Android.Tasks.ResolveAssemblies.AddAssemblyReferences(DirectoryAssemblyResolver resolver, ICollection`1 assemblies, AssemblyDefinition assembly, Boolean topLevel)
       at Xamarin.Android.Tasks.ResolveAssemblies.Execute(DirectoryAssemblyResolver resolver)   app.Android         

Can anyone help me out to how to bind a .net library dll into the project so that it can be used in xamarin forms.

Another alternative is agsXMPP .NET SDK but am not sure much of it.

If i missed something. Sorry for that

1

1 Answers

0
votes

First remove sharp nuget and clone this. https://github.com/pgstath/Sharp.Xmpp . Open the solution of sharp and build it. You will get Sharp.Xmpp.dll under bin\debug. Add reference of this .dll to your project.