Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Why does viewstate deserialize object as hashtable?

Reply
Thread Tools

Why does viewstate deserialize object as hashtable?

 
 
jw56578@gmail.com
Guest
Posts: n/a
 
      04-07-2005
I have an object that inherits from hashtable and is serializable to be
stored in the viewstate, but when I retrieve it from viewstate, it is
converted into a hashtable, why won't it stay as the original object?
thanks

 
Reply With Quote
 
 
 
 
Teemu Keiski
Guest
Posts: n/a
 
      04-07-2005
Hi,

Your question is confusing. Define what means "it is converted into
HashTable" (post the code). Do you mean that you are handed with Hashtable
instance even though it is derived from HT (did you do casting to the
derived type after getting object from the Viewstate and got exceptions)?

I'd like to see the sample code. And you did specify serialization by
appending Serializable attribute or did you reimplement ISerializable
inetrface implemented by HT?

One reason I'm thinking for this, is that Hashtable implements ISerializable
interface, and I suppose it could be possible that its default
implementation is used (which would instantiate Hashtable), unless you
redeclare it. (though it sounds weird)

--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU

<> wrote in message
news: oups.com...
>I have an object that inherits from hashtable and is serializable to be
> stored in the viewstate, but when I retrieve it from viewstate, it is
> converted into a hashtable, why won't it stay as the original object?
> thanks
>



 
Reply With Quote
 
 
 
 
PJ
Guest
Posts: n/a
 
      04-07-2005
> One reason I'm thinking for this, is that Hashtable implements
ISerializable
> interface, and I suppose it could be possible that its default
> implementation is used (which would instantiate Hashtable), unless you
> redeclare it. (though it sounds weird)


That's exactly right. Asp.net calls the ISerializable methods and since you
do not override the appropriate methods in your derived object, it uses the
hashtables implementation...which, of course, only serializes and
deserializes itself.


 
Reply With Quote
 
jw56578@gmail.com
Guest
Posts: n/a
 
      04-09-2005
when i say converts it to a hashtable, i mean that the type of the
deserialized object is Hashtable, not my original object.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Deserialize XML-File to Axis-generated Object pico77 Java 1 07-29-2008 07:18 AM
findcontrol("PlaceHolderPrice") why why why why why why why why why why why Mr. SweatyFinger ASP .Net 2 12-02-2006 03:46 PM
Save Object to file , how to using Serialization and deserialize moonhk Java 4 10-24-2006 11:52 AM
Save ViewState to server - deserialize is very slow mohaaron@gmail.com ASP .Net 2 04-25-2006 08:46 PM
Serialize and deserialize object to and from text Edmond wong Java 2 04-29-2005 04:21 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57