Xamarin使用DataContractJsonSerializer用于Android空白应用程序 [英] Xamarin Using DataContractJsonSerializer for Android Blank App

本文介绍了Xamarin使用DataContractJsonSerializer用于Android空白应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用DataContractJsonSerializer,但似乎无法获得参考/命名空间。
我在.NET Framework 4.5上创建了我的应用。

I am trying to use DataContractJsonSerializer but I can't seem to get a reference/namespace for it. I created my app on a .NET Framework 4.5.

当我单击添加引用时,我仅获得System.ServiceModel的2.0.5.0版本。 >

When I click add reference I only get the version 2.0.5.0 for System.ServiceModel

推荐答案

如果要使DataContractJsonSerializer与Android一起使用,则需要创建一个PCL项目,然后该项目将在名称空间System.Runtime下可用。串行化

If you want to get DataContractJsonSerializer working with Android you would need to create a PCL project and then it would be available under namespace System.Runtime.Serialization.Json. This would require a Xamarin business license or higher to work.

更好的选择是使用Json.NET(如果多次使用,它比DataContractJsonSerializer快得多)或ServiceStack.Text(很多比Json.NET快)。 XLabs提供了与移动设备兼容的序列化程序的抽象( Nuget,搜索XLabs.Serialization )并具有Json.NET,ServiceStack.Text(v3),ProtoBuf&当然是DataContractSerializer(.NET XML序列化器)。数据包中省略了DataContractJsonSerializer,因为它需要营业执照,并且实际上在Json.NET或ServiceStack上提供的内容并不多。

Better option would be to use Json.NET (much faster than DataContractJsonSerializer if you use it more than once) or ServiceStack.Text (much faster than Json.NET). XLabs offers an abstraction on mobile compatible serializers (Nuget, search for XLabs.Serialization) and has plugins for Json.NET, ServiceStack.Text (v3), ProtoBuf & of course DataContractSerializer (.NET XML serializer). DataContractJsonSerializer is omitted from the package since it requires business license and really doesn't offer much over Json.NET or ServiceStack.

这篇关于Xamarin使用DataContractJsonSerializer用于Android空白应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆