Not logged in. · Lost password · Register
Forum: agsXMPP RSS
Avatar
ramtin #1
User title: RamTin
Member since Mar 2013 · 26 posts
Group memberships: Members
Show profile · Link to this post
Subject: Getting Error in Private chat
Hi Alex
agsXMPP
c#

i give some error ,
when a user comming to my private , and i close ChatFormWindow , and he/she send me a new pm , i give a error , how can i fixed ?

error msg=>
Item has already been added . Key in Dictionary 4@localhost  key being added: 4@localhost

My Code
  1.                     if (msg.Body != null)
  2.                     {
  3.                         try
  4.                         {
  5.                             if (!Chat.Contains(msg.From.Bare))
  6.                             {
  7.                                 string nick = msg.From.Bare;
  8.                                 frmChat fm = new frmChat(msg.From, Xmpp, nick);
  9.                                 fm.Show();
  10.                                 fm.IncomingMessage(msg);
  11.                             }
  12.                             else
  13.                                 Chat.Remove(msg.From.Bare);
  14.                         }
  15.                         catch (Exception ex) { MessageBox.Show(ex.Message); }
  16.                     }
  17.                     else
  18.                         return;

i test your samples but it dident open FrmChatWindow for once more ! but my code is opening 1 more time and when he/she send a new message to me , i give that error .

thanks
This post was edited on 2013-10-11, 08:30 by Alex.
Avatar
Alex #2
Member since Feb 2003 · 4449 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
as the error message sais you are adding an entry (key) to a collection which already exists.
This problem is not related to any MatriX code directly. So check code which Adds items to a collection.
Close Smaller – Larger + Reply to this post:
Verification code: VeriCode Please enter the word from the image into the text field below. (Type the letters only, lower case is okay.)
Smileys: :-) ;-) :-D :-p :blush: :cool: :rolleyes: :huh: :-/ <_< :-( :'( :#: :scared: 8-( :nuts: :-O
Special characters:
Forum: agsXMPP RSS