I created an object and use the constructors along the lines of this link
I dont get any errors writing or reading but when I try to assign myObject the serialized info I get an "Unable to find assembly" error.
any idea
TimeSobject newTimeObject = new TimeSobject(); newTimeObject.barCount= CurrentBar; newTimeObject.closePx = 9999; Print("serilization srted"); Stream stream = File.Open(Cbi.Core.UserDataDir.ToString() + "Cereal.osl", FileMode.Create); BinaryFormatter bin = new BinaryFormatter(); bin.Serialize(stream, newTimeObject); stream.Close(); Print("serilization complete"); newTimeObject = null; stream = File.Open(Cbi.Core.UserDataDir.ToString() + "Cereal.osl", FileMode.Open); Print("serilization 1"); bin = new BinaryFormatter(); Print("serilization 2"); newTimeObject = (TimeSobject)bin.Deserialize(stream); //Error here! Print("serilization 3"); stream.Close(); Print("serilization 4"); Print(newTimeObject.closePx.ToString() + " is the close price from serilzation");
public TimeSobject(SerializationInfo info, StreamingContext ctxt) { //Get the values from info and assign them to the appropriate properties barCount = (int)info.GetValue("barCount", typeof(int)); closePx = (double)info.GetValue("ClosePX", typeof(double)); } //Serialization function. public void GetObjectData(SerializationInfo info, StreamingContext ctxt) { //You can use any custom name for your name-value pair. But make sure you // read the values with the same name. For ex:- If you write closePx as "ClosePX" // then you should read the same with "ClosePX" info.AddValue("barCount", barCount); info.AddValue("ClosePX", closePx); }
Comment