Getting serialization error. The class implements ISerializable.
Is there any resolution to this.

thanks
Niranjan

Re: Unable to pass Dictionary class instance over Webservice by Kevin

Kevin
Wed Jun 07 10:37:26 CDT 2006

Hi Niranjan,

XML Serialization is a type of Serialization. But most types of
Serialization are not XML Serialization, and not everything marked as
Iserialzable can be serialized as XML. Let me clarify a bit, and I'll leave
you with a couple of online references you can study.

Serialization (the general term) is the process of transforming an object to
a stream or an array of bytes (the 2 are almost the same). I prefer to refer
to it as "Binary" Serialization because it makes it easier to differentiate
between Serialization and XML Serialization, but I can understand why
Microsoft does not, because in fact, both XML Serialization and
Serialization are used to serialize binary objects, and Serialization can be
used to serialize data as a string rather than simply an array of bytes (2
very similar types as well, but not quite as closely related). But the
differences, while seemingly subtle, are quite important.

First, XML Serialization *always* serializes data to an XML stream or
string. "Binary" Serialization does not. "Binary" Serialization simply
serializes the data as a stream or string, without XML markup. It is used to
serialize classes to a file system, or in Remoting, or any other process
which does not use XML.

Second, the difference between a string and an array of bytes is that a
string can be text of any encoding, character set, or language. Some strings
(like ASCII strings, for example) store a character in a single byte.
Others, like Unicode, store a character in 2, 3 or 4 bytes. A string must be
"translated" from a sequence of bytes into a sequence of characters, using
the encoding, character set, and language of the string. All characters in a
string are exactly the same number of bytes each.

A binary array of bytes is simply that: an array of bytes. The data in the
array may be comprised of data that is of nearly any length, in various
combinations. So, a binary array is "translated" by using some form of
schema that indicates what the types stored in the array are, and the order
in which they are stored.

Bottom line is, you have to handle each of these in a different way. Here
are a couple of references on these general topics:

http://msdn2.microsoft.com/en-us/library/system.runtime.serialization.iserializable.aspx
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconintroducingxmlserialization.asp

Now, while most types that implement ISerializable *can* be serialized as
XML, classes derived from System.Collections.IDictionary cannot. The good
news is, there is a way around this. It can be done by wrapping an
IDictionary class instance in another class and implementing
System.Xml.IXmlSerializable. There is a piece that details this in the
following MSDN magazone article:

http://msdn.microsoft.com/msdnmag/issues/03/06/XMLFiles/default.aspx

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Chicken Salad Alchemist

A lifetime is made up of
Lots of short moments.

"Niranjan" <Niranjan@discussions.microsoft.com> wrote in message
news:2939E4D8-699B-4BA1-A164-182798787233@microsoft.com...
> Getting serialization error. The class implements ISerializable.
> Is there any resolution to this.
>
> thanks
> Niranjan



Re: Unable to pass Dictionary class instance over Webservice by Niranjan

Niranjan
Thu Jun 08 00:52:01 CDT 2006

Hi Kevin,

Thanks for the info. I was able to implement the solution and it worked.

Thanks
Niranjan


"Kevin Spencer" wrote:

> Hi Niranjan,
>
> XML Serialization is a type of Serialization. But most types of
> Serialization are not XML Serialization, and not everything marked as
> Iserialzable can be serialized as XML. Let me clarify a bit, and I'll leave
> you with a couple of online references you can study.
>
> Serialization (the general term) is the process of transforming an object to
> a stream or an array of bytes (the 2 are almost the same). I prefer to refer
> to it as "Binary" Serialization because it makes it easier to differentiate
> between Serialization and XML Serialization, but I can understand why
> Microsoft does not, because in fact, both XML Serialization and
> Serialization are used to serialize binary objects, and Serialization can be
> used to serialize data as a string rather than simply an array of bytes (2
> very similar types as well, but not quite as closely related). But the
> differences, while seemingly subtle, are quite important.
>
> First, XML Serialization *always* serializes data to an XML stream or
> string. "Binary" Serialization does not. "Binary" Serialization simply
> serializes the data as a stream or string, without XML markup. It is used to
> serialize classes to a file system, or in Remoting, or any other process
> which does not use XML.
>
> Second, the difference between a string and an array of bytes is that a
> string can be text of any encoding, character set, or language. Some strings
> (like ASCII strings, for example) store a character in a single byte.
> Others, like Unicode, store a character in 2, 3 or 4 bytes. A string must be
> "translated" from a sequence of bytes into a sequence of characters, using
> the encoding, character set, and language of the string. All characters in a
> string are exactly the same number of bytes each.
>
> A binary array of bytes is simply that: an array of bytes. The data in the
> array may be comprised of data that is of nearly any length, in various
> combinations. So, a binary array is "translated" by using some form of
> schema that indicates what the types stored in the array are, and the order
> in which they are stored.
>
> Bottom line is, you have to handle each of these in a different way. Here
> are a couple of references on these general topics:
>
> http://msdn2.microsoft.com/en-us/library/system.runtime.serialization.iserializable.aspx
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconintroducingxmlserialization.asp
>
> Now, while most types that implement ISerializable *can* be serialized as
> XML, classes derived from System.Collections.IDictionary cannot. The good
> news is, there is a way around this. It can be done by wrapping an
> IDictionary class instance in another class and implementing
> System.Xml.IXmlSerializable. There is a piece that details this in the
> following MSDN magazone article:
>
> http://msdn.microsoft.com/msdnmag/issues/03/06/XMLFiles/default.aspx
>
> --
> HTH,
>
> Kevin Spencer
> Microsoft MVP
> Professional Chicken Salad Alchemist
>
> A lifetime is made up of
> Lots of short moments.
>
> "Niranjan" <Niranjan@discussions.microsoft.com> wrote in message
> news:2939E4D8-699B-4BA1-A164-182798787233@microsoft.com...
> > Getting serialization error. The class implements ISerializable.
> > Is there any resolution to this.
> >
> > thanks
> > Niranjan
>
>
>