Serialization Issue.

I'm trying to serialize an object that inherits from System.Web.UI.Page. This is the error I get.

The property 'ClientID' on type 'System.Web.UI.Control' cannot be serialized because it is decorated with declarative security permission attributes. Consider using imperative asserts or demands in the property accessors.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Why are you trying to serialize it and can you show your code?
I dont believe you can serialize this class.  If you must, I think your best bet is to implement the Memento pattern or inherit from it and implement ISerializable.  Either way, you're looking at a bit of work to get around it.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
derekthorntonAuthor Commented:
Joy ...Can you not serialize an interface?
You can't directly serialize an interface (because you can't create an instance of an interface) but you can serialize a class that implements an interface.  Not with XmlSerializer, though, but the BinarySerializer can do it just fine.
derekthorntonAuthor Commented:
I found a good workaround for what I wanted to do.

Instead of using an interface or Serializing the class, I create an XmlSerializable Attribute that I can attach to things. I can make other custom attributes to inherit from XmlSerializable and Inject those into a class, and those inherited Attributes can contain all of the methods/properties I need to serialize. Thanks for the information on Interfaces, that's what I was looking for.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.