mixerp / MixERP.Net.VCards

vCard Serializer and Parser for C#
Apache License 2.0
70 stars 42 forks source link

Dont work #19

Open tohoff82 opened 4 years ago

tohoff82 commented 4 years ago

System.ArgumentException: An item with the same key has already been added. Key: TYPE at System.Collections.Generic.Dictionary2.TryInsert(TKey key, TValue value, InsertionBehavior behavior) at MixERP.Net.VCards.Parser.TokenParser.GetAdditionalKeyMembers(String data) at MixERP.Net.VCards.Parser.TokenParser.GetToken(String line) at MixERP.Net.VCards.Parser.TokenParser.Parse(String contents) at MixERP.Net.VCards.Deserializer.GetVCard(String contents) at System.Linq.Enumerable.SelectArrayIterator2.ToList() at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source) at MixERP.Net.VCards.Deserializer.GetVCards(String contents)

DasMaffin commented 3 years ago

My fix was extracting it and putting a try catch around the dictionary.Add(key, value) in the method VCardUtil.GetAdditionalKeyMembers Its everything else but beautiful but it makes it work

kiquenet commented 3 years ago

I use Nuget, and I get: System.ArgumentException: An item with the same key has already been added.

Which is the key ?

IEnumerable vcards = MixERP.Net.VCards.Deserializer.Deserialize(vcfMovil);

        string contents = File.ReadAllText(vcfMovil, Encoding.UTF8);
        IEnumerable<VCard> vcards2 = MixERP.Net.VCards.Deserializer.GetVCards(contents);

        foreach (var vcard in vcards2)
        {
            Console.WriteLine(vcard.FirstName + " \t " + vcard.MiddleName + " " + vcard.LastName);
            Console.WriteLine(vcard.FormattedName);
        }