Home All Groups Group Topic Archive Search About

Problem: Serializing with <NonSerialized>

Author
23 Feb 2006 10:48 AM
Ehsan
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.

Author
23 Feb 2006 9:50 PM
Frans Bouma [C# MVP]
Ehsan wrote:

> Does this attribute really work?

    Yes it really does :)

> 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.

    Check if the form isn't refered to via another route. Also, are you
implementing ISerializable on the class?

        FB


--
------------------------------------------------------------------------
Get LLBLGen Pro, productive O/R mapping for .NET: http://www.llblgen.com
My .NET blog: http://weblogs.asp.net/fbouma
Microsoft MVP (C#)
------------------------------------------------------------------------

AddThis Social Bookmark Button