带有Sharp.XMPP库的Xamarin.Forms可移植类库项目

时间:2015-09-04 10:45:59

标签: c# android xmpp xamarin.forms portable-class-library

我的项目中出现了一个特定问题。我发现只有一个支持Android的C#库(在Xamarin中):Sharp.XMPPNuGet,但我遇到了麻烦。当我在分离的可移植类库中编写一些示例代码时,我会收到以下错误:

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

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

下一步:

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 

我很无能为力。 提前谢谢。

2 个答案:

答案 0 :(得分:0)

当较低的库使用不同版本的.NET Framework时,也会发生这种情况。 您尝试在您使用的相同版本的.NET Framework上更新de库,它应该可以工作。

答案 1 :(得分:0)

Sharp.XmppPCL不兼容,因为它使用的XmlElement类目前在PCL中无法使用。

重写此部分是可行的,但需要付出巨大努力。

我使用的解决方法是开发.Net 4.5类库,引用Sharp.XMPPWindows.Net之间的可移植性是通过Xamarin实现的。

希望这有帮助

相关问题