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

╄→尐↘猪︶ㄣ 提交于 2019-12-20 06:38:18

问题


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.


回答1:


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




回答2:


This also happens when a lower library is using a different version of the .NET Framework. You try to update de library at the same version of the .NET Framework that you use and it should work.



来源:https://stackoverflow.com/questions/32396159/xamarin-forms-portable-class-library-project-with-sharp-xmpp-library

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!