Alberto said:
Yes, we would like to serialize it via BinaryFormatter on a file on
disk.
FileInfo f = new FileInfo(filename);
Stream myStream = f.OpenWrite();
BinaryFormatter myBinaryFormat = new BinaryFormatter();
myBinaryFormat.Serialize(myStream, myLinkedList);
myStream.Close();
This code works without any problems on my machine, for a trivial LinkedList
with only one element. So again: what's the *specific* error you run into?
There is no *fundamental* restriction on serializing a LinkedList, so
without more details of what "myLinkedList" is exactly and why it's not
working for you it's impossible to guess.
Here's the easy test for the most obvious thing that could be going wrong,
though: is your custom class actually serializable? Simply marking it
[Serializable] is not enough: all of its members (public and private) have
to be serializable too, for starters. Can you successfully serialize
individual instances of your class outside the LinkedList?