Problem: Serialization with <NonSerialized>

G

Guest

Does this attribute really work?
I'm trying to "deep" serialize one of my objects which has a member variable
pointing to a Form object. I don't want to serialize this form (and I know
that I can't do this anyway because the Form class is not marked as
Serializable). I try marking this member variable with the <NonSerialized>
attribute, but the BinaryFormatter seems to be ignoring this attribute; It
throws an exeption "Class frmReport {some info about the class here} can not
be serialized, because it is not marked as Serializable"
Is there any other way to prevent the serialization of a member variable
that I don't know?
Thanx everyone.
 
R

R. MacDonald

Hello, Ehsan,

Are you delegating any of the Form's events to a handler in an object
that is being serialized? This can be a problem, as the serialization
will want to serialize the delegate and then also the form.

Cheers,
Randy
 

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