In that case it needs the serializable attribute on the class like this...
[Serializable]
public class YourClass
質問
I'm trying to serialize object with following procedure:
public static byte[] ObjectToByteArray(Object obj) {
if (obj == null)
return null;
using (MemoryStream ms = new MemoryStream()) {
BinaryFormatter bf = new BinaryFormatter();
bf.Serialize(ms, obj);
return ms.ToArray();
}
}
I've got break point on bf.Serialize(ms, obj);
and I can check that my object is fine there but when I go to the next step it just breaks operation without any errors or saying anything. I even don't know how should I debug it for now. Any ideas?
解決
In that case it needs the serializable attribute on the class like this...
[Serializable]
public class YourClass