views:

76

answers:

1

Hello.

I have an excepction while trying to serialize an Stack in Visual Studio 2008, C# 3.5

Here is some sample code.

> 1     CardDN kk = new CardDN(12, CardDN.SuitType.Clubs);
> 2     Stack<CardDN> kk1 = new Stack<CardDN>();
> 3     kk1.Push(kk);
> 4    
> 5     XmlSerializer serializerk = new XmlSerializer(kk1.GetType());
> 6     StringWriter auxSerializedk = new StringWriter();
> 7     serializerk.Serialize(auxSerializedk, kk1);

It fails in line 5. Exception is this one:

Debe implementar el descriptor de acceso predeterminado en System.Collections.Generic.Stack`1[[BlackJack.CardDN, DN_BlackJack, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]] porque hereda de ICollection.

In english is something like:

"Must implement default access descriptor in System.Collections.Generic.Stack`1[[BlackJack.CardDN, DN_BlackJack, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]] because inherits from ICollection.

I've read that LISTs could be XML-Serialized but Dictionarys don't. I guess Stacks don't. How can I "implement the default access descriptor"? I couldn't find anything in google. (Maybe because my translation of the exception is not the same it is)

I really need a Stack there. Don't want to use a List.

Any idea? Thanks

A: 

Perhaps it's "must implement a default constructor"?

Dark Falcon