Hi,
IStateManager means that object itself implements a interface similar to
controls which have state management capability, means objects themselves
save something (their current state) to view state (IStateMamager declares
the inetrface for these saving/loading/tracking methods), but object
instances itself are not put into the view state.
E.g state and instances are kept separately (instances are recreated on
postback and view state is then loaded to them to restore the state).
IStateManager is meant to obejcts which aren't controls but work in the same
context for example control styles, ListItems and so on.
If you put object instances to ViewState, their implementation of
IStateManager has nothing to do with this process but as error message
indicates, in that case objects must have Serializable attribute applied to
the class for automatic serialization and you can further customize this
process by implementing ISerializable interface.
--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
[quoted text, click to view] "Rowland Shaw" <spamfilter@anotherpointless.org> wrote in message
news:416E3293-A203-40C8-9127-0A3B2D3BB0BE@microsoft.com...
> All the documentation I've found suggects that all you need to support on
> your object to stick it in the ViewState on a control is the IStateManager
> interface.
>
> However, with the IStateManager interface implemented (in my example on
> ComplexObject), I get the infamous error:
> [HttpException (0x80004005): The type 'MyCompany.MyProject.ComplexObject'
> must be marked as Serializable or have a TypeConverter other than
> ReferenceConverter to be put in viewstate.]
>
> There's been a lot of head scratching, and a lot of flicking through pages
> 245 to 255 of MS Press' "Developing Asp.Net Server Controls and
> Components";
> but I'm still no wiser -- am I missing something blindingly obvious or is
> there really an amount of black magic required? (I suspect the former)