[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework

Is IDictionary serializable ?

Oriane

6/26/2008 3:33:00 PM

Hi there,

in an Asp.net application, a class GfProjects I used in a Profile implements
IDictionary. The class is marked as [Serializable] and the profiles appear
to be saved and read succesfully. However, I've build an Asp.Net web service
which gets this profile field, and when I test it on IE, I get the following
message:

"Cannot serialise member XXX.GfProjects of type
System.Collections.Generic.Dictionary`2[[System.String, mscorlib,
Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089],[Gilif.Auth.GilifProject, Gilif.Auth,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=4df35566e5ba3853]], since
it is implementing IDictionary."

So what ?

Oriane

4 Answers

mwilson

6/26/2008 4:08:00 PM

0

On Jun 26, 11:33 am, "Oriane" <ori...@noemail.noemail> wrote:
> Hi there,
>
> in an Asp.net application, a class GfProjects I used in a Profile implements
> IDictionary. The class is marked as [Serializable] and the profiles appear
> to be saved and read succesfully. However, I've build an Asp.Net web service...

You're serializing using two different serialization methods here:
binary (or possibly soap) which works and xml serialization which
doesn't. XML Serialization is what's used by the web service.

This author seems to have a workaround you can use:

http://msmvps.com/blogs/rakeshrajan/archive/2006/01/15/...

sloan

6/26/2008 6:21:00 PM

0


You can check this blog entry:
http://sholliday.spaces.live.co...!A68482B9628A842A!114.entry

Its 1.1 centric however.



"Oriane" <oriane@noemail.noemail> wrote in message
news:B1218AED-9C16-4F22-800F-E25648E4CA72@microsoft.com...
> Hi there,
>
> in an Asp.net application, a class GfProjects I used in a Profile
> implements IDictionary. The class is marked as [Serializable] and the
> profiles appear to be saved and read succesfully. However, I've build an
> Asp.Net web service which gets this profile field, and when I test it on
> IE, I get the following message:
>
> "Cannot serialise member XXX.GfProjects of type
> System.Collections.Generic.Dictionary`2[[System.String, mscorlib,
> Version=2.0.0.0, Culture=neutral,
> PublicKeyToken=b77a5c561934e089],[Gilif.Auth.GilifProject, Gilif.Auth,
> Version=1.0.0.0, Culture=neutral, PublicKeyToken=4df35566e5ba3853]], since
> it is implementing IDictionary."
>
> So what ?
>
> Oriane


Pavel Minaev

6/28/2008 4:07:00 PM

0

On Jun 26, 7:33 pm, "Oriane" <ori...@noemail.noemail> wrote:

> in an Asp.net application, a class GfProjects I used in a Profile implements
> IDictionary. The class is marked as [Serializable] and the profiles appear
> to be saved and read succesfully. However, I've build an Asp.Net web service
> which gets this profile field, and when I test it on IE, I get the following
> message:
>
> "Cannot serialise member XXX.GfProjects of type
> System.Collections.Generic.Dictionary`2[[System.String, mscorlib,
> Version=2.0.0.0, Culture=neutral,
> PublicKeyToken=b77a5c561934e089],[Gilif.Auth.GilifProject, Gilif.Auth,
> Version=1.0.0.0, Culture=neutral, PublicKeyToken=4df35566e5ba3853]], since
> it is implementing IDictionary."
>
> So what ?

In the second case, you're actually using XML serialization via
XmlSerializer. That one, indeed, does not support IDictionary for some
obscure reasons (though you can write your own class that implements
IDictionary but is serializable regardless - if you implement
IXmlSerializable explicitly).

On a side note, if you migrate your web service to WCF instead, you
won't have this problem - it uses DataContractSerializer instead of
XmlSerializer, and the former fully supports IDictionary,

Oriane

6/30/2008 8:42:00 AM

0

Hi Pavel,
<"Pavel Minaev" <int19h@gmail.com> a écrit dans le message de
news:fd1fecdd-0eef-4337-80ee-<c81d074b53bd@x35g2000hsb.googlegroups.com...
<In the second case, you're actually using XML serialization via
<XmlSerializer. That one, indeed, does not support IDictionary for some
<obscure reasons (though you can write your own class that implements
<IDictionary but is serializable regardless - if you implement
<IXmlSerializable explicitly).
Ok then...

<On a side note, if you migrate your web service to WCF instead, you
<won't have this problem - it uses DataContractSerializer instead of
<XmlSerializer, and the former fully supports IDictionary,
Yes it seems to be the best choice...

Thanks to you (and Sloan and mWilson)

Oriane