Problem in putting object in ViewState

  • Thread starter Thread starter Makarand
  • Start date Start date
M

Makarand

Hi Friends

I have collection class implementing from IList.
Problem I am facing is I am not able to put this object in
ViewState(though it is going in Session). When I try to do
this it gives error like -- "The
type 'IListStuff.PersonCollection' must be marked as
Serializable or have a TypeConverter other than
ReferenceConverter to be put in viewstate"

So I made my class serializable as shown below,

namespace IListStuff
{
[Serializable]
public class GenericDOCollection : IList
........
}

But it is still giving me same error, I don't know about
the second part of error message i.e. TypeConvertor.

Can anybody help me in solving this problem.

Thanks

Regards
Makarand
 
Does your type contain members of another class that may not be
serializable? You may have to mark particular fields as NonSerialized if
they don't support serialization.
 
Hi Chris

Thanks, that was the mistake i was doing

Makarand
-----Original Message-----
Does your type contain members of another class that may not be
serializable? You may have to mark particular fields as NonSerialized if
they don't support serialization.

--
Chris Jackson
Software Engineer
Microsoft MVP - Windows XP
Windows XP Associate Expert
--
More people read the newsgroups than read my email.
Reply to the newsgroup for a faster response.
(Control-G using Outlook Express)
--

Hi Friends

I have collection class implementing from IList.
Problem I am facing is I am not able to put this object in
ViewState(though it is going in Session). When I try to do
this it gives error like -- "The
type 'IListStuff.PersonCollection' must be marked as
Serializable or have a TypeConverter other than
ReferenceConverter to be put in viewstate"

So I made my class serializable as shown below,

namespace IListStuff
{
[Serializable]
public class GenericDOCollection : IList
........
}

But it is still giving me same error, I don't know about
the second part of error message i.e. TypeConvertor.

Can anybody help me in solving this problem.

Thanks

Regards
Makarand


.
 
I have the same problem.

I have a custom Principal class, I have marked the "Identity" property using the XmlElement attribute as "Ignore". This works fine when I use the XML serializer to store it in a FormsAuthentication cookie, but I get the same error if I try to store it in the ViewState? Does the View State serializer not use the XML Serializer? How should I tell the serializer to ignore the "Identity" property when it's getting placed in the VIewState?
 
No, never mind my never mind. You CAN'T mark a property as NonSerialized, only a field

You can't make the Identity property on a class implementing IPrinicipal a public field. So you can't mark it NonSerialized there either.
 
Back
Top