Skip to content Skip to sidebar Skip to footer

Can I Serialize Htmlagilitypack.htmldocument

Server Error in '/' Application. Type 'HtmlAgilityPack.HtmlDocument' in Assembly 'HtmlAgilityPack, Version=1.4.0.0, Culture=neutral, PublicKeyToken=bd319b19eaf3b43a' is not marked

Solution 1:

Based on the fact that the exception states the class is not marked as serializable, I would say "no". Question: why are you storing an HtmlDocument object in the session? Why not store it as text?

Solution 2:

Based on the exception, the class is not marked to be serializable.

One way that you would be able to serialize the HtmlDocument would be to create a class that mimics that class, copy all of the properties from one to the other and serialize your copy. Or, you could download the sources, edit the HtmlDocument class to be serializable, and recompile and reference that in your project

You could use a class such as AutoMapper to map the properties back and forth, so that you're not writing all the mapping code yourself.

Post a Comment for "Can I Serialize Htmlagilitypack.htmldocument"