serialization problem

Mar 10 2010 8:19 PM

I have a class that need to be serialized.. i use bynary formaters for serialisation.. there is event in that class and in the main form ( form 1 ) there is object from the class i need to serialze.., and there is method for the event, also located in form 1.. so because of that method i can't serialze object from form1.. i get exception Form1 not marked as serializable..
so how can I serialize my object?
here some code about it..
[serializable]
public class MyClass
{
some properties..

one publicĀ  delegate..

one public event...

}
public partial class Form1: Form
{
public Form1()

{


MyClass obMyClass = new MyClass();
obMyClass.eventName +=new MyClass.delegateName (newMethod); // if I coment this line everything is fine..
// but if not, when i try to serialize obMyClass, i get exception (Form1 not mark as serializable), so please if anyone can help me..


}
public void newMethod()
{ some code here..}

}

Answers (1)