Copy/ paste problem

Hello everybody,
I have also an copy paste problem. It does not work.
I insert this code to analyse the problem:
Stream ofile = File.Open(“test.graph”, FileMode.Create);
IFormatter oformatter = new BinaryFormatter();
oformatter.Serialize(ofile, myView.Document);
(Thanks to Walter for this code .)
But then this exception occurs :
Message = “Type ‘Northwoods.Go.GoView’ in Assembly ‘Northwoods.Go, Version=, Culture=neutral, PublicKeyToken=a4e3b7b70161cfe8’ is not marked as serializable.”
That can not be right I think.
Have you got any idea why this exception occurs? The GoView class is serializable I think.
Some background information that can maybe helpful:
- I have a derived class of GoView which is serializable.
- The project I implemented for is component based.

GoView, like all WindowsForms Controls, is not serializable – one can only serialize references to them, which doesn’t do any good when you want to copy and paste and expect to reconstruct the same data structures.
Apparently you have a reference to a GoView in your data structures. That’s not permitted, mostly for this reason, but also because it violates the model/view separation that GoDocument/GoObject is trying to maintain apart from any GoView/GoTool/GoSelection et al.
Hence your GoDocument and GoObject classes should not have any fields that refer to GoView, directly or indirectly.