Serialization problem, "is not marked as serializable" error for UserControl

N

nirdeshonline

Hi,

I am serializing a custom class holding some data for my project.

This data internally contains a class which contains an event

public delegate void MemberModifiedEventHandler(object sender,
MemberModifiedEventArgs e);

/// <summary>

/// Occurs on modification in a group.

/// </summary>

public event MemberModifiedEventHandler OnMembersModified;



This sender brings in a CutomPage derived from
System.Windows.Forms.UserControl.

I do not need to serialize this class as it contains only UI and has
got nothing to be saved and serialized.

But when i serialize the data it gives the error "CutomPage is not
marked as serializable".

How can i come across this problem without serializing this page.



NonSerializable attribute does not work for events and classes.



How can i serialize my data without serializing these usercontrol
clases.



Waiting for a kind reply.

Thanks & Regards

Nirdesh Dabas

(e-mail address removed)
 
N

Nicholas Paldino [.NET/C# MVP]

Nirdesh,

Have you tried applying it to the field on the event, like so?

[field:NonSerializable]
public event EventHandler MyEvent;

That should work.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top