private static byte[] toByteArray(System.Object o) { if (o == null) { return(null); } /*need to synchronize use of the shared baos */ System.IO.MemoryStream baos = new System.IO.MemoryStream(); System.IO.BinaryWriter oos = new System.IO.BinaryWriter(baos); SupportClass.Serialize(oos, o); oos.Flush(); return(baos.ToArray()); }