Search code examples
c#androidxmppxamarin.formsportable-class-library

Xamarin.Forms Portable Class Library Project with Sharp.XMPP library


an specific issue has occured in my project. I've found only one library for C# supporting Android (in Xamarin): Sharp.XMPP, NuGet, but I have troubles with it. When I write some sample code in separated portable class library, I get these errors:

Error 1: '.ctor' is not supported by the language

by the line

using (XmppClient client = new XmppClient(hostname, username, password))
            {
              ...
            }

Next:

Error 2: Metadata file '...\Project.Jabber.dll' could not be found  
Warnings 2-6: Reference to type 'System.Net.Security.RemoteCertificateValidationCallback' claims it is defined in 'c:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETPortable\v4.5\Profile\Profile78\System.dll', but it could not be found   c:\Users\Kliford\Downloads\S22.Xmpp\S22.Xmpp.dll 

I am clueless. Thank you in advance.


Solution

  • Sharp.Xmpp is not compatible with PCL since it uses the XmlElement class, which is not currently available in PCL.

    Rewriting this part is doable, but requires a significant effort.

    The workaround that I use, is to develop .Net 4.5 Class libraries, which reference Sharp.XMPP. Portability among Windows and .Net is achieved through Xamarin.

    Hope this helps