Not logged in. · Lost password · Register
Forum: agsXMPP SDK Support RSS
Source array was not long enough. Check srcIndex and length, and the array's lower bounds.
Avatar
owen #1
Member since Nov 2006 · 21 posts · Location: UK
Group memberships: Members
Show profile · Link to this post
Subject: Strange error
I am occassionally (apparently randomly) getting the following exception in my VB.Net code which uses agsXMPP:

Source array was not long enough. Check srcIndex and length, and the array's lower bounds.

This happens intermittently (maybe 1 in 50 times) when I use the .Send method.  Here is a copy of my example code where the exception occurrs (very occasionally, so chances are you won't see the error if you run this code!).


Dim XMPP As agsXMPP.XmppClientConnection
Dim oMsg As agsXMPP.protocol.client.Message = New agsXMPP.protocol.client.Message
Dim ToUserJid as String = "recipient@myserver"
Dim FromUserJid as STring = "me@myserver"
oMsg.MsgType = agsXMPP.protocol.client.MessageType.chat
oMsg.Subject = "message subject"
oMsg.To = New agsXMPP.Jid(ToUserJID)
oMsg.Body = "message body"
oMsg.From = New agsXMPP.Jid(FromUserJID)

XMPP.Send(oMsg)
oMsg = Nothing


Is there anything wrong with my code?   What does the error mean?  Is there a simple fix I can apply?

I have searched this forum but found no definitive answer.

Thanks!
Owen
Avatar
Alex #2
Member since Feb 2003 · 4246 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
I assume this is not the complete code because you don't set the properties o your xmpp connection and you never open it.
Other than this the code looks correct, but we never set the message object to nothing and leave it to the garbage collector.

Aöex
Alexander Gnauck
AG-Software
Avatar
Alex #3
Member since Feb 2003 · 4246 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
can you post the stacktrace of the exception, to see where exactly the error occurs?

Alex
Alexander Gnauck
AG-Software
Avatar
owen #4
Member since Nov 2006 · 21 posts · Location: UK
Group memberships: Members
Show profile · Link to this post
Hi Alex,  yes you're right that's not the entire code, I just posted the bit which does the sending -- and the connection happens elsewhere before that.

The stack trace is as follows:

Stack trace:    at System.Array.Copy(Array sourceArray, Int32 sourceIndex, Array destinationArray, Int32 destinationIndex, Int32 length, Boolean reliable)
   at System.Collections.Queue.SetCapacity(Int32 capacity)
   at System.Collections.Queue.Enqueue(Object obj)
   at agsXMPP.net.ClientSocket.Send(Byte[] bData)
   at agsXMPP.net.ClientSocket.Send(String data)
   at agsXMPP.XmppConnection.Send(String xml)
   at agsXMPP.XmppConnection.Send(Element e)
   at XonMessenger2.Form1.SendToSite(String ToUserID, String Message, String SendToSiteNumber)


Hope this helps...!
Avatar
Alex #5
Member since Feb 2003 · 4246 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Can you get the line where the exception occurs from the debugger?
Alexander Gnauck
AG-Software
Avatar
owen #6
Member since Nov 2006 · 21 posts · Location: UK
Group memberships: Members
Show profile · Link to this post
It fails on oXMPP.Send(oMsg) - but agian I shoudl say it happens apparently at random, and is not consistently failing.
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 SDK Support RSS