This project has moved and is read-only. For the latest updates, please go here.

Cannot Bind after deserializing.

Nov 26, 2009 at 10:13 PM
Edited Nov 27, 2009 at 12:33 PM

This is for the CF. Haven't tried it on desktop yet.

While i get my objects over TCP and deserializing them in BusinessObject[]

then i create a List<BusinessObject>. If i try to bind this list i get a NotSupportedException.

This is not a control problem tried in 3 different controls, and all through the same exception.

If i try to create 100 BusinessObjects through a for loop everything works as expected.

I need help with this cause else all goes bang!

[EDITED] I must say, Serializing is happening with Desktop library, Deserializing with Compact Framework library.

I paste code for Serializing and Deserializing:



    public class Serialize
        public static byte[] SerializePro(object obj)
            JsonConverter[] converters = new JsonConverter[] { new BinaryConverter() };
            string dataString = JsonConvert.SerializeObject(obj, converters);
            return Encoding.UTF8.GetBytes(dataString);

        public static DataPackage DeserializePro(byte[] obj)
            string dataString = Encoding.UTF8.GetString(obj, 0, obj.Length);
            JsonConverter[] converters = new JsonConverter[] { new BinaryConverter() };
            DataPackage packet = JsonConvert.DeserializeObject<DataPackage>(dataString, converters);
            return packet;

Maybe i should mention that i use in the DataPackage object a byte[] Property which contains other Serialized data (BusinessObject(s)).
This gives us Serialized data into Serialized data and i dont know if this is a problem. I Guess not cause if i dont bind in DataSource
and extract properties one by one works ok.

Serializing on Desktop:

            Product[] prodsArray = new Product[100];
            for (int i = 0; i < prodsArray.Length; i++)
                prodsArray[i] = new Product(i, "Test " + i.ToString());
            byte[] dataArray = Serialize.SerializePro(prodsArray);
            DataPackage packet = new DataPackage
                                         Data = dataArray,
                                         Command = CommandInOrder.None
            byte[] packetData = Serialize.SerializePro(packet);

Send with TCP the packetData....
Receive over TCP the packetData and Deserialize...

            DataPackage packet = Serialize.DeserializePro(packetData);
            string dataString = Encoding.UTF8.GetString(packet.Data, 0, packet.Data.Length);
            JsonConverter[] converters = new JsonConverter[] { new BinaryConverter() };            
prodsArray = JsonConvert.DeserializeObject<Product[]>(dataString);
List<Product> Products = new List<Product>(prodsArray.Length);
dataGrid1.DataSource = Products; <-- NotSupportedException...

Thank you.


Dec 2, 2009 at 12:27 AM

Hmmm I don't know.

Could you post the full NotSupportedException stacktrace message?

Dec 2, 2009 at 1:19 AM

I thought i posted here!


It was Threading problem not serializer....Json works great!