Silverlight如何把二进制数据转实体
使用wcf返回压缩后的byte()数据
然后在客户端解压..想转换成制定类型的数据...
在wcf端使用的是
Dim formatter As IFormatter = New System.Runtime.Serialization.Formatters.Binary.BinaryFormatter()
Dim stream_ As New MemoryStream()
formatter.Serialize(stream_, p_PagePackage)
Dim buffer_all As Byte() = stream_.ToArray()
stream_.Close()
但是在silverlight端没有IFormatter
尝试使用
Private Sub ws_DoWorkCompleted(ByVal sender As Object, ByVal e As ServiceReference1.DoWorkCompletedEventArgs)
Dim memStream As New MemoryStream(CType(e.Result, Byte()))
Dim ser As New Runtime.Serialization.DataContractSerializer(GetType(String))
Dim _value As String = ser.ReadObject(memStream)
End Sub
报错ReadObject,"."(16进制值0x00)是无效的字符
求解!
[解决办法]
全部byte之后再赋给一个对象就可以了